package net.tycmc.cty.ctyms.timejob.iems.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import net.tycmc.bulb.common.dao.IBaseDAO;
import net.tycmc.bulb.common.dao.ITransactionDAO;
import net.tycmc.bulb.common.util.DateUtil;
import net.tycmc.bulb.common.util.MapGetter;
import net.tycmc.bulb.common.util.StringUtil;
import net.tycmc.cty.ctyms.timejob.common.EquipVersionCommon;

public class VclParamStatConn {
	
	private String checkTable = "";//小一 校验表存在
	private String lastWorkDay = "";//上次统计的时间
	private String thisWorkDay = "";//这次统计时间
	private StringBuffer thisUpdateFirst = null;//当日安装设备的更新语句
	private List<String> thisUpdateSQLList = null;//当日安装设备的更新语句序列，存在当日安装设备时进行new
	private List<Object[]> thisUpdateParamList = null;//当日安装设备的更新语句参数序列，存在当日安装设备时进行new
	
	private StringBuffer nullInsertSQL = null;//无当日定时表或者can参数表时的录入语句
	
	private IBaseDAO baseDAO;
	
	private ITransactionDAO tranDAO;

	public IBaseDAO getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(IBaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}

	public ITransactionDAO getTranDAO() {
		return tranDAO;
	}

	public void setTranDAO(ITransactionDAO tranDAO) {
		this.tranDAO = tranDAO;
	}
	/**
	 * 大一设备统计工作参数，仪表里程存0.0
	 * 
	 **/
	private void makeParamsOfBoVcl() {
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		Map<String,Object> mapA = baseDAO.execQueryOne(checkTable, new Object[]{"Msg_Timing_"+this.thisWorkDay.replaceAll("-", "")});
		String boAllSoftVerTerm = EquipVersionCommon.getSoftVerByAgrType("Vcl_D");
		if(null!=mapA&&MapGetter.getString(mapA, "counts").equals("1")){
			/*大一设备工作参数统计：工作小时数、油耗、里程**/
			StringBuffer strBuff = new StringBuffer();
			strBuff.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons,MsgSTP_iIdleOil," +
					"MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU," +
					                                                          "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,MsgSTP_tIdleOil," +
					"MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
			
			strBuff.append("select VehicleInfo.VehicleID,CAST(round(convert(float,ISNULL(tmp.ECM-" +
			        "(select case when 0=ISNULL(MsgSTP_tEWorkHours,0) then (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleInfo.VehicleID and MsgT_tEWork is not null and MsgT_tEWork >0 order by MsgT_MsgTime) else MsgSTP_tEWorkHours end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
					
			/*		"case(ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.ECM) else " +
					"(select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.ETDistance-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.ETDistance),0))*1.0,2) as decimal(18,2)) as iETDistance,");
			*/
			
			strBuff.append("null as iETDistance,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.tOilCons-" +
					"(select case when 0=ISNULL(MsgSTP_tOilCons,0) then (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleInfo.VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime) else MsgSTP_tOilCons end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iOilCons,");
			
			/*		"case(ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tOilCons) else  " +
					"(select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iOilCons,");*/
			strBuff.append("null as iIdleOil,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKm-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKmExact,0) then (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleInfo.VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by MsgT_MsgTime) else MsgSTP_tRunKmExact end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
			
			/*		"case(ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.MsgT_tRunKm) else  " +
					"(select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmExact,");*/
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKm1-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKm,0) then (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleInfo.VehicleID and MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 order by MsgT_MsgTime) else MsgSTP_tRunKm end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iRunKm,");
			
			/*		"case(ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.MsgT_tRunKm1) else " +
					"(select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKm,");*/
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKmECU-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKmECU,0) then (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleInfo.VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by MsgT_MsgTime) else MsgSTP_tRunKmECU end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
			
			/*		"case(ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.MsgT_tRunKmECU) else " +
					"(select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmECU,");*/
			
			strBuff.append("tEWorkHours=case when tmp.ECM is not null and tmp.ECM>0 then tmp.ECM else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
//			strBuff.append("tETDistance=case when tmp.ETDistance is not null and tmp.ETDistance>0 then tmp.ETDistance else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			strBuff.append("tETDistance=null,");
			
			strBuff.append("tOilCons=case when tmp.tOilCons is not null and tmp.tOilCons>0 then tmp.tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			strBuff.append("tIdleOil=null,");
			strBuff.append("tRunKmExact=case when tmp.MsgT_tRunKm is not null and tmp.MsgT_tRunKm>0 then tmp.MsgT_tRunKm else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tRunKm=case when tmp.MsgT_tRunKm1 is not null and tmp.MsgT_tRunKm1>0 then tmp.MsgT_tRunKm1 else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			strBuff.append("tRunKmECU=case when tmp.MsgT_tRunKmECU is not null and tmp.MsgT_tRunKmECU>0 then tmp.MsgT_tRunKmECU else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("? ");
			strBuff.append("from V_VehicleInfo as VehicleInfo left join ( ");
			
			strBuff.append("select *,ETDistance = CASE WHEN MsgT_tRunKm1 IS NOT NULL  THEN MsgT_tRunKm1 WHEN MsgT_tRunKm1 IS NULL  AND MsgT_tRunKm IS NOT NULL  THEN MsgT_tRunKm ELSE Isnull(MsgT_tRunKmECU,0) ");
			strBuff.append("END from ( SELECT VehicleID,ECM = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tEWork is not null and MsgT_tEWork >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime desc ), ");
			strBuff.append("MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 order by MsgT_MsgTime desc ), ");
			strBuff.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by MsgT_MsgTime desc ) ");
			
			strBuff.append("FROM  V_VehicleInfo ) bo ");
			strBuff.append(")as tmp on ");
			strBuff.append("tmp.VehicleID = VehicleInfo.VehicleID ");
			strBuff.append("where UsefulLife>=GETDATE() ");
			strBuff.append("and Tmnl_SoftEdition in ("+boAllSoftVerTerm+");");
			baseDAO.execInsert(strBuff.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			
			
			/*大一，当天数据处理**/
			StringBuffer firstDataHandlerSqlBo = new StringBuffer();
			firstDataHandlerSqlBo.append("select * from Message_Stat_TimingParam left join V_VehicleInfo on MsgSTP_VclID=VehicleID " +
					"where MsgSTP_StatTime='"+this.thisWorkDay+"' and (MsgSTP_iOilCons=-999999999 or MsgSTP_iEWorkHours=-999999999 " +
					"or MsgSTP_iRunKmExact=-999999999 or MsgSTP_iRunKm=-999999999 or MsgSTP_iRunKmECU=-999999999 ) ");
			List<Map<String,Object>> firstDataHandlerList_BO = baseDAO.execQuery(firstDataHandlerSqlBo+" and Tmnl_SoftEdition in("+boAllSoftVerTerm.toString()+")", new Object[]{});
			
			if(null!=firstDataHandlerList_BO&&firstDataHandlerList_BO.size()>0){//当日安装过大一设备
				StringBuffer paramKmSql_BO = new StringBuffer();
				paramKmSql_BO.append("select tmp.tKm-tmp1.tKm iKm, tmp.MsgT_tOilCons-tmp1.MsgT_tOilCons iOil, " +
						"tmp.MsgT_tEWork-tmp1.MsgT_tEWork iTime, tmp.MsgT_tRunKm-tmp1.MsgT_tRunKm iRunKmExact, " +
						"tmp.MsgT_tRunKm1-tmp1.MsgT_tRunKm1 iRunKm, tmp.MsgT_tRunKmECU-tmp1.MsgT_tRunKmECU iRunKmECU from (");
				paramKmSql_BO.append("SELECT tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end,* from "+
						"(SELECT MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tOilCons is not null and MsgT_tOilCons >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
						"MsgT_tEWork = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tEWork is not null and MsgT_tEWork >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
						"MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm is not null and MsgT_tRunKm >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
						"MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
						"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc) "+
						"FROM V_VehicleInfo where VehicleID = ? ) bo0 ) tmp LEFT JOIN ( ");
				paramKmSql_BO.append("SELECT tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end,* from "+
						"(SELECT MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tOilCons is not null and MsgT_tOilCons >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
						"MsgT_tEWork = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tEWork is not null and MsgT_tEWork >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
						"MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm is not null and MsgT_tRunKm >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
						"MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
						"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc) "+
						"FROM V_VehicleInfo where VehicleID = ? ) bo1 ) tmp1 ON 1 = 1 where 1=1 ");
				this.thisUpdateSQLList = new ArrayList<String>(); 
				this.thisUpdateParamList = new ArrayList<Object[]>(); 
				for(Map<String,Object> oneBo:firstDataHandlerList_BO){
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramKmSql_BO.toString(),new Object[]{MapGetter.getString(oneBo, "MsgSTP_VclID"),MapGetter.getString(oneBo, "MsgSTP_VclID")});
					
					this.thisUpdateSQLList.add(this.thisUpdateFirst.toString());
					this.thisUpdateParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),"0.0",
							this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
							MapGetter.getString(oneBo, "MsgSTP_ID")});
				}
				if(this.thisUpdateSQLList.size()>0){
					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
					this.thisUpdateSQLList = null;
					this.thisUpdateParamList = null;
				}
			}
		}else{
			String workSQL313 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+boAllSoftVerTerm+")";
			baseDAO.execInsert(workSQL313, new Object[]{this.thisWorkDay});
		}
	}
	/**
	 * 小一J设备工作参数，
	 **/
	private void makeParamsOfBoCanVcl(StringBuffer firstDataHandlerSql) {
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		Map<String,Object> msgCan = baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_CAN_"+tableDate+""});
		Map<String,Object> msgCanCont = baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_CAN_Content_"+tableDate+""});
		String soJSoftVerTerm = EquipVersionCommon.getSoftVerByAgrType("Vcl_J");
		if(null!=msgCan&&null!=msgCanCont&&MapGetter.getString(msgCan, "counts").equals("1")&&MapGetter.getString(msgCanCont, "counts").equals("1")){
			StringBuffer strBuff403 = new StringBuffer();	
				strBuff403.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons," +
			     "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,MsgSTP_StatTime)");
				
				strBuff403.append("select VehicleID,CAST(round(convert(float,ISNULL(tmp.ECM-" +
						"(select case when 0=ISNULL(MsgSTP_tEWorkHours,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tEWorkHours end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				strBuff403.append("null as iETDistance,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tOilCons-" +
						"(select case when 0=ISNULL(MsgSTP_tOilCons,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tOilCons end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iOilCons,");
				
				strBuff403.append("tEWorkHours=case when tmp.ECM is not null and tmp.ECM>0 then tmp.ECM else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tETDistance=null,");
				
				strBuff403.append("tOilCons=case when tmp.tOilCons is not null and tmp.tOilCons>0 then tmp.tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("? ");
				
				strBuff403.append("from ( select * ");
				
				strBuff403.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				
				strBuff403.append("FROM  V_VehicleInfo AS vehicleinfo where  UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+soJSoftVerTerm+") )can ) tmp where 1=1 ");
				
				baseDAO.execInsert(strBuff403.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			
				/**2014-07-16 fujichuan 已更新的方式统计新增的四个里程**/
				StringBuffer update403 = new StringBuffer();
				update403.append("update message_stat_timingparam set MsgSTP_iMeterDistance = tmpt.imeterdistance,MsgSTP_iRunKmExact = tmpt.irunkmexact, MsgSTP_iRunKm = tmpt.iRunKm,MsgSTP_iRunKmECU =tmpt.irunkmecu,");
				update403.append("MsgSTP_tMeterDistance = tmpt.tmeterdistance, MsgSTP_tRunKmExact = tmpt.trunkmexact, MsgSTP_tRunKm = tmpt.trunkm, MsgSTP_tRunKmECU = tmpt.trunkmecu ");
				update403.append("from (SELECT vehicleid,");
				update403.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tkm4 - (SELECT CASE WHEN 0 = Isnull(msgstp_tmeterdistance,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 53  AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime) ELSE msgstp_tmeterdistance END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS imeterdistance,");
				update403.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tkm1 - (SELECT CASE WHEN 0 = Isnull(msgstp_trunkmexact,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 27 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime)ELSE msgstp_trunkmexact END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS irunkmexact,");
				update403.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tkm2 - (SELECT CASE WHEN 0 = Isnull(msgstp_trunkm,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 28 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime)ELSE msgstp_trunkm END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS irunkm,");
				update403.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tkm3 - (SELECT CASE WHEN 0 = Isnull(msgstp_trunkmecu,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 29 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime)ELSE msgstp_trunkmecu END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS irunkmecu,");
				update403.append("tmeterdistance = CASE WHEN tmp.tkm4 IS NOT NULL AND tmp.tkm4 > 0 THEN tmp.tkm4 ELSE Isnull((SELECT msgstp_tmeterdistance FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0) END,");
				update403.append("trunkmexact = CASE WHEN tmp.tkm1 IS NOT NULL AND tmp.tkm1 > 0 THEN tmp.tkm1 ELSE Isnull((SELECT msgstp_trunkmexact FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0) END,");
				update403.append("trunkm = CASE WHEN tmp.tkm2 IS NOT NULL AND tmp.tkm2 > 0 THEN tmp.tkm2 ELSE Isnull((SELECT msgstp_trunkm FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0) END,");
				update403.append("trunkmecu = CASE WHEN tmp.tkm3 IS NOT NULL AND tmp.tkm3 > 0 THEN tmp.tkm3 ELSE Isnull((SELECT msgstp_trunkmecu FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0)END ");
				update403.append("from(SELECT vehicleid,tkm1 = (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 27 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime DESC),");
				update403.append("tkm2 = (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 28 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime DESC),");
				update403.append("tkm3 = (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 29 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime DESC),");
				update403.append("tkm4 = (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				update403.append("WHERE msgcco_syscp_id = 53 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime DESC)");
				update403.append("FROM v_vehicleinfo AS vehicleinfo WHERE UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+soJSoftVerTerm+"))tmp ) tmpt where MsgSTP_VclID = tmpt.VehicleID and MsgSTP_StatTime = ?");
				baseDAO.execUpdate(update403.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,
					this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
				
				/**2014-07-16 fujichuan 已更新的方式统计新增的怠速耗油量**/
				StringBuffer updateIdOil403 = new StringBuffer();
				updateIdOil403.append("update message_stat_timingparam set msgstp_iidleoil = tmpt.iidleoil,msgstp_tidleoil = tmpt.tidleoil ");
				updateIdOil403.append("FROM (select vehicleid,");
				updateIdOil403.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tidleoil - (SELECT CASE WHEN 0 = Isnull(msgstp_tidleoil,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				updateIdOil403.append("WHERE msgcco_syscp_id = 24 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime)ELSE msgstp_tidleoil END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS iidleoil,");
				updateIdOil403.append("tidleoil = CASE WHEN tmp.tidleoil IS NOT NULL AND tmp.tidleoil > 0 THEN tmp.tidleoil ELSE Isnull((SELECT msgstp_tidleoil FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0) END ");
				updateIdOil403.append("from(SELECT vehicleid,tidleoil = (SELECT   top 1  msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
				updateIdOil403.append("WHERE msgcco_syscp_id = 24 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid  ORDER BY msgc_msgtime DESC)FROM v_vehicleinfo AS vehicleinfo ");
				updateIdOil403.append("WHERE UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+soJSoftVerTerm+"))tmp");
				updateIdOil403.append(") tmpt where MsgSTP_VclID = tmpt.VehicleID and MsgSTP_StatTime = ?");
				baseDAO.execUpdate(updateIdOil403.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
				
				//小一（403），当天数据处理
			List<Map<String,Object>> firstDataHandlerList_403 = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+soJSoftVerTerm+")", new Object[]{});
			
				
				StringBuffer paramSql_SO = new StringBuffer();
				paramSql_SO.append("select tmp.ECM-tmp1.ECM iTime,tmp.tETDistance-tmp1.tETDistance iKm,tmp.tOilCons-tmp1.tOilCons iOil, tmp.tIdleOil - tmp1.tIdleOil iIdleOil, " +
				                   "tmp.tKm4-tmp1.tKm4 iMeterDistance,tmp.tKm1-tmp1.tKm1 iRunKmExact,tmp.tKm2-tmp1.tKm2 iRunKm,tmp.tKm3-tmp1.tKm3 iRunKmECU from (");
				paramSql_SO.append("select *,tETDistance=case when can.tKm2 is not null then can.tKm2 when can.tKm1 is not null then can.tKm1 else isnull(can.tKm3,0) end ");
				paramSql_SO.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				paramSql_SO.append("tIdleOil = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can ) tmp ");
				paramSql_SO.append("LEFT JOIN (select *,tETDistance=case when can1.tKm2 is not null then can1.tKm2 when can1.tKm1 is not null then can1.tKm1 else isnull(can1.tKm3,0) end ");
				paramSql_SO.append("from ( SELECT VehicleID, ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc)  ");
				paramSql_SO.append("tIdleOil = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc) ");
				paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can1 ) tmp1 ON 1 = 1  where 1=1 ");
				
				this.thisUpdateSQLList = new ArrayList<String>();
				this.thisUpdateParamList = new ArrayList<Object[]>();
				
				for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList_403){
					
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramSql_SO.toString(), 
							new Object[]{
										MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
										MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID")
									});
					this.thisUpdateSQLList.add(this.thisUpdateFirst.toString());
					this.thisUpdateParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),this.getFloat(paramMap, "iIdleOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),this.getFloat(paramMap, "iMeterDistance"),
							this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
							MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
				}
				if(this.thisUpdateSQLList.size()>0){
					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
					this.thisUpdateSQLList = null; 
					this.thisUpdateParamList = null;
				}
			
		}else{
			String workSQL403 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+soJSoftVerTerm+")";
			baseDAO.execInsert(workSQL403, new Object[]{this.thisWorkDay});
		}
	}
	/**
	 * 小一J设备工作参数，
	 **/
	private void makeParamsOfBoCanVcl_bak(StringBuffer firstDataHandlerSql) {
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		Map<String,Object> msgCan = baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_CAN_"+tableDate+""});
		Map<String,Object> msgCanCont = baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_CAN_Content_"+tableDate+""});
		String soJSoftVerTerm = EquipVersionCommon.getSoftVerByAgrType("403");
		if(null!=msgCan&&null!=msgCanCont&&MapGetter.getString(msgCan, "counts").equals("1")&&MapGetter.getString(msgCanCont, "counts").equals("1")){
			String selVclSQL403 = "select VehicleID from V_VehicleInfo where UsefulLife>=GETDATE() and Tmnl_SoftEdition in ("+soJSoftVerTerm+");";
			List<Map<String,Object>> vclList403 = baseDAO.execQuery(selVclSQL403, new Object[]{});
			StringBuffer strBuff403 = new StringBuffer();
			String vclId403 = null;
			for(Map<String,Object> one403:vclList403){
				strBuff403.setLength(0);
				vclId403 = MapGetter.getString(one403, "VehicleID");
				
				strBuff403.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons," +
				"MsgSTP_iIdleOil,MsgSTP_iMeterDistance,MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU,"+		
						                                                             "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons," +
				"MsgSTP_tIdleOil,MsgSTP_tMeterDistance,MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_tIdleOil,MsgSTP_StatTime)");
				
				strBuff403.append("select VehicleID,CAST(round(convert(float,ISNULL(tmp.ECM-" +
						"(select case when 0=ISNULL(MsgSTP_tEWorkHours,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tEWorkHours end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				/*		"case(ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.ECM) else " +
						"(select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.ETDistance-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.ETDistance),0))*1.0,2) as decimal(18,2)) as iETDistance,");
				*/
				strBuff403.append("null as iETDistance,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tOilCons-" +
						"(select case when 0=ISNULL(MsgSTP_tOilCons,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tOilCons end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iOilCons,");
				
						/*"case(ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tOilCons) else " +
						"(select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iOilCons,");*/
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tIdleOil-" +
						"(select case when 0=ISNULL(MsgSTP_tIdleOil,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tIdleOil end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iIdleOil,");
				
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm4-" +
						"(select case when 0=ISNULL(MsgSTP_tMeterDistance,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tMeterDistance end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
						/*"case(ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tKm4) else " +
						"(select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iMeterDistance,");*/
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm1-" +
						"(select case when 0=ISNULL(MsgSTP_tRunKmExact,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tRunKmExact end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
				
				/*		"case(ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tKm1) else " +
						"(select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmExact,");*/
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm2-" +
						"(select case when 0=ISNULL(MsgSTP_tRunKm,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tRunKm end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iRunKm,");
				
				/*		"case(ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tKm2) else " +
						"(select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKm,");*/
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm3-" +
						"(select case when 0=ISNULL(MsgSTP_tRunKmECU,0) then (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID " +
						" WHERE MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime) else MsgSTP_tRunKmECU end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
						",0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
				
				/*		"case(ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tmp.tKm3) else " +
						"(select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmECU,");*/
				
				strBuff403.append("tEWorkHours=case when tmp.ECM is not null and tmp.ECM>0 then tmp.ECM else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
//				strBuff403.append("tETDistance=case when tmp.ETDistance is not null and tmp.ETDistance>0 then tmp.ETDistance else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff403.append("tETDistance=null,");
				
				strBuff403.append("tOilCons=case when tmp.tOilCons is not null and tmp.tOilCons>0 then tmp.tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tIdleOil=case when tmp.tIdleOil is not null and tmp.tIdleOil>0 then tmp.tIdleOil else ISNULL((select MsgSTP_tIdleOil from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tMeterDistance=case when tmp.tKm4 is not null and tmp.tKm4>0 then tmp.tKm4 else ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKmExact=case when tmp.tKm1 is not null and tmp.tKm1>0 then tmp.tKm1 else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKm=case when tmp.tKm2 is not null and tmp.tKm2>0 then tmp.tKm2 else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKmECU=case when tmp.tKm3 is not null and tmp.tKm3>0 then tmp.tKm3 else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("? ");
				
				strBuff403.append("from ( select *,ETDistance=case when can.tKm2 is not null then can.tKm2 when can.tKm1 is not null then can.tKm1 else isnull(can.tKm3,0) end ");
				
				strBuff403.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tIdleOil = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				
				strBuff403.append("FROM  V_VehicleInfo AS vehicleinfo where VehicleID = "+vclId403+" )can ) tmp where 1=1 ");
				
				baseDAO.execInsert(strBuff403.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			}
			
			//小一（403），当天数据处理
			List<Map<String,Object>> firstDataHandlerList_403 = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+soJSoftVerTerm+")", new Object[]{});
			
				
				StringBuffer paramSql_SO = new StringBuffer();
				paramSql_SO.append("select tmp.ECM-tmp1.ECM iTime,tmp.tETDistance-tmp1.tETDistance iKm,tmp.tOilCons-tmp1.tOilCons iOil, tmp.tIdleOil - tmp1.tIdleOil iIdleOil, " +
				                   "tmp.tKm4-tmp1.tKm4 iMeterDistance,tmp.tKm1-tmp1.tKm1 iRunKmExact,tmp.tKm2-tmp1.tKm2 iRunKm,tmp.tKm3-tmp1.tKm3 iRunKmECU from (");
				paramSql_SO.append("select *,tETDistance=case when can.tKm2 is not null then can.tKm2 when can.tKm1 is not null then can.tKm1 else isnull(can.tKm3,0) end ");
				paramSql_SO.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				paramSql_SO.append("tIdleOil = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can ) tmp ");
				paramSql_SO.append("LEFT JOIN (select *,tETDistance=case when can1.tKm2 is not null then can1.tKm2 when can1.tKm1 is not null then can1.tKm1 else isnull(can1.tKm3,0) end ");
				paramSql_SO.append("from ( SELECT VehicleID, ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
				paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc)  ");
				paramSql_SO.append("tIdleOil = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 24  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc) ");
				paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can1 ) tmp1 ON 1 = 1  where 1=1 ");
				
				this.thisUpdateSQLList = new ArrayList<String>();
				this.thisUpdateParamList = new ArrayList<Object[]>();
				
				for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList_403){
					
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramSql_SO.toString(), 
							new Object[]{
										MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
										MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID")
									});
					this.thisUpdateSQLList.add(this.thisUpdateFirst.toString());
					this.thisUpdateParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),this.getFloat(paramMap, "iIdleOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),this.getFloat(paramMap, "iMeterDistance"),
							this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
							MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
				}
				if(this.thisUpdateSQLList.size()>0){
					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
					this.thisUpdateSQLList = null; 
					this.thisUpdateParamList = null;
				}
			
		}else{
			String workSQL403 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+soJSoftVerTerm+")";
			baseDAO.execInsert(workSQL403, new Object[]{this.thisWorkDay});
		}
	}
	/**
	 * 412设备工作参数统计，高精度里程、ECU里程 null
	 **/
	private void makeParamsOfPPVcl(StringBuffer firstDataHandlerSql,boolean existBTiming) {
		String termSoftVer412 = EquipVersionCommon.getSoftVerByAgrType("Vcl_PP");
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		if(existBTiming){
			StringBuffer strBuff412 = new StringBuffer();
			strBuff412.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons,MsgSTP_iIdleOil,");
			strBuff412.append("MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,MsgSTP_tIdleOil,MsgSTP_StatTime) ");
			
			strBuff412.append("select VehicleID,CAST(round(convert(float,ISNULL(MsgT_tWorkTime_UDS-" +
					"(select case when 0=ISNULL(MsgSTP_tEWorkHours,0) then (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime)" +
					" else MsgSTP_tEWorkHours end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			/*		"case(ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
			strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tWorkTime_UDS) " +
					"else (select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			strBuff412.append("CAST(round(convert(float,ISNULL(MsgT_tRunKm_UDS-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
			strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKm_UDS),0))*1.0,2) as decimal(18,2)) as iETDistance,");*/
			
			strBuff412.append(" null as iETDistance,");
			
			strBuff412.append("CAST(round(convert(float,ISNULL(MsgT_tOilCons_UDS-" +
					"(select case when 0=ISNULL(MsgSTP_tOilCons,0) then (select top 1 MsgT_tOilCons_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime)" +
					" else MsgSTP_tOilCons end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iOilCons,");
					/*"case(ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
			strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tOilCons_UDS) " +
					"else (select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iOilCons,");*/
			strBuff412.append("iIdleOil=null,");			
			strBuff412.append("tEWorkHours=case when MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 then MsgT_tWorkTime_UDS else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
//			strBuff412.append("tETDistance=case when MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS>0 then MsgT_tRunKm_UDS else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			strBuff412.append("tETDistance=null,");
			
			strBuff412.append("tOilCons=case when MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS>0 then MsgT_tOilCons_UDS else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			strBuff412.append("tIdleOil=null,");
			strBuff412.append("? ");
			strBuff412.append("from (SELECT VehicleID,MsgT_tRunKm_UDS  = (select top 1 MsgT_tRunKm_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), ");
			strBuff412.append("MsgT_tOilCons_UDS = (select top 1 MsgT_tOilCons_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), ");
			strBuff412.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc)  ");
			strBuff412.append("FROM  V_VehicleInfo WHERE  UsefulLife >= Getdate() AND Tmnl_SoftEdition <> '' AND Tmnl_SoftEdition IS NOT NULL  AND Tmnl_SoftEdition IN ("+termSoftVer412.toString()+")) tmpTab  where 1 = 1 ");
			
			//baseDAO.execInsert(strBuff412.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			baseDAO.execInsert(strBuff412.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			
			/**
			 * 更新PP设备的仪表里程  【ECM高精度总里程】【ECM总里程】【ECU总里程】为null
			 **/		
			boolean existParamU = false;
			Map<String,Object> msgU = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_UDS_"+tableDate});
			Map<String,Object> msgUCont = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_UDS_Content_"+tableDate});
			if(null!=msgU&&null!=msgUCont&&MapGetter.getString(msgU, "counts").equals("1")&&MapGetter.getString(msgUCont, "counts").equals("1")){
				existParamU = true;
			}
			if(existParamU){
				String selVclSQL412 = "select mst.MsgSTP_ID,VehicleID from Message_Stat_TimingParam mst inner join V_VehicleInfo vv on mst.MsgSTP_VclID = vv.VehicleID " +
						"where 1=1 and mst.MsgSTP_StatTime = '"+this.thisWorkDay+"' and  UsefulLife>=GETDATE() and Tmnl_SoftEdition in ("+termSoftVer412.toString()+");";
				String updateSQL = "update Message_Stat_TimingParam set MsgSTP_iMeterDistance = ? , MsgSTP_tMeterDistance = ? where MsgSTP_ID = ? "; 
				List<Map<String,Object>> vclList412 = this.baseDAO.execQuery(selVclSQL412, new Object[]{});
				if(null!= vclList412 && vclList412.size()>0){
					this.thisUpdateSQLList = new ArrayList<String>();
					this.thisUpdateParamList = new ArrayList<Object[]>();
					String mstID;
					String vclID;
					Map<String,Object> meterMap;
					StringBuffer queryUDSMeter = new StringBuffer();
					queryUDSMeter.append("select CAST(round(convert(float,ISNULL(mu.MsgU_tMeterDis- (case when 0=Isnull(MsgSTP_tMeterDistance,0) then ma.MsgU_tMeterDis" +					
					        " else MsgSTP_tMeterDistance end),0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
//							"case (ISNULL(MsgSTP_tMeterDistance,0)) when 0 then (999999999+MsgU_tMeterDis) else MsgSTP_tMeterDistance end,0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
					
					queryUDSMeter.append("ISNULL(ISNULL(mu.MsgU_tMeterDis,MsgSTP_tMeterDistance),0) tMeterDistance from Message_Stat_TimingParam mst left join ");
					queryUDSMeter.append("(select top 1 MsgU_Vcl_ID,CONVERT(float,MsgUC_UDSValue) as MsgU_tMeterDis from CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+" on MsgUC_MsgU_ID = MsgU_ID ");
					queryUDSMeter.append("where MsgU_Vcl_ID = ? and MsgUC_UDSID='3027' and MsgUC_UDSValue is not null and CONVERT(float,MsgUC_UDSValue)>0 order by MsgU_MsgTime desc ) mu on MsgSTP_VclID = mu.MsgU_Vcl_ID ");
					queryUDSMeter.append("left join (select top 1 MsgU_Vcl_ID,CONVERT(float,MsgUC_UDSValue) as MsgU_tMeterDis from CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+" on MsgUC_MsgU_ID = MsgU_ID ");
					queryUDSMeter.append("where MsgU_Vcl_ID = ? and MsgUC_UDSID='3027' and MsgUC_UDSValue is not null and CONVERT(float,MsgUC_UDSValue)>0 order by MsgU_MsgTime ) ma on MsgSTP_VclID = ma.MsgU_Vcl_ID ");
					queryUDSMeter.append("where MsgSTP_VclID = ? and MsgSTP_StatTime = ? ");
					for(Map<String,Object> one412:vclList412){
						mstID = MapGetter.getString(one412,"MsgSTP_ID");
						vclID = MapGetter.getString(one412,"VehicleID");
						meterMap = this.baseDAO.execQueryOne(queryUDSMeter.toString(), new Object[]{vclID,vclID,vclID,this.lastWorkDay});
						if(null != meterMap && !meterMap.isEmpty()){//查询的该设备的仪表里程不可能null值，故不再判断具体参数值
							this.thisUpdateSQLList.add(updateSQL);
							this.thisUpdateParamList.add(new Object[]{MapGetter.getString(meterMap, "iMeterDistance"),MapGetter.getString(meterMap, "tMeterDistance"),mstID});
						}
					}
					if(this.thisUpdateSQLList.size()>0){
						tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
						this.thisUpdateSQLList = null; 
						this.thisUpdateParamList = null;
					}
				}
			}
			
			//当日安装的412设备统计参数
			List<Map<String,Object>> firstDataHandlerList412 = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+termSoftVer412.toString()+")", new Object[]{});
			if(null!=firstDataHandlerList412 && firstDataHandlerList412.size()>0 ){
				StringBuffer paramKmSql = new StringBuffer("select tmp.MsgT_tRunKm_UDS-tmp1.MsgT_tRunKm_UDS iKm,tmp.MsgT_tOilCons_UDS-tmp1.MsgT_tOilCons_UDS iOil,");
				paramKmSql.append("tmp.MsgT_tWorkTime_UDS-tmp1.MsgT_tWorkTime_UDS iTime from ");
				paramKmSql.append("(SELECT MsgT_tRunKm_UDS = (select top 1 MsgT_tRunKm_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc),");
				paramKmSql.append("MsgT_tOilCons_UDS =(select top 1 MsgT_tOilCons_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc),");
				paramKmSql.append("MsgT_tWorkTime_UDS =(select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc) ");
				paramKmSql.append("FROM  V_VehicleInfo where VehicleID = ?) tmp LEFT JOIN ( ");
				paramKmSql.append("SELECT  MsgT_tRunKm_UDS = (select top 1 MsgT_tRunKm_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc),");
				paramKmSql.append("MsgT_tOilCons_UDS =(select top 1 MsgT_tOilCons_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc),");
				paramKmSql.append("MsgT_tWorkTime_UDS =(select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc) ");
				paramKmSql.append("FROM  V_VehicleInfo where VehicleID = ?) tmp1 ON 1 = 1 where 1=1 ");
				
				StringBuffer meterDistanceSql = new StringBuffer();
				meterDistanceSql.append("select CONVERT(float,tmpE.MsgUC_UDSValue)-CONVERT(float,tmpB.MsgUC_UDSValue) iMeterDistance from ( ");
				meterDistanceSql.append("select top 1 MsgU_Vcl_ID,MsgUC_UDSValue,MsgU_MsgTime from CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" ");
				meterDistanceSql.append("inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+"  on MsgUC_MsgU_ID=MsgU_ID "
						+"where MsgUC_UDSID='3027' and MsgUC_UDSValue is not null  and MsgU_Vcl_ID=? order by MsgU_MsgTime asc)tmpB ");
				meterDistanceSql.append("left join ( select top 1 MsgU_Vcl_ID,MsgUC_UDSValue,MsgU_MsgTime from CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" ");
				meterDistanceSql.append("inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+"  on MsgUC_MsgU_ID=MsgU_ID "
						+"where MsgUC_UDSID='3027' and MsgUC_UDSValue is not null  and MsgU_Vcl_ID=? order by MsgU_MsgTime desc)tmpE on 1=1 where 1=1 ");
				
				this.thisUpdateSQLList = new ArrayList<String>();
				this.thisUpdateParamList = new ArrayList<Object[]>();
				for(Map<String,Object> one412:firstDataHandlerList412){
					this.thisUpdateSQLList.add(this.thisUpdateFirst.toString());
					String VclID = MapGetter.getString(one412, "MsgSTP_VclID");
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramKmSql.toString(), new Object[]{VclID,VclID});
					Map<String,Object> paramMapMeter = baseDAO.execQueryOne(meterDistanceSql.toString(), new Object[]{VclID,VclID});
					this.thisUpdateParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),this.getFloat(paramMapMeter, "iMeterDistance"),"0.0","0.0","0.0",
							MapGetter.getString(one412, "MsgSTP_ID")});
				}
				if(this.thisUpdateSQLList.size()>0){
					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
					this.thisUpdateSQLList = null; 
					this.thisUpdateParamList = null;
				}
			}
		}else{
			String workSQL412 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+termSoftVer412+")";
			baseDAO.execInsert(workSQL412, new Object[]{this.thisWorkDay});
		}	
	}
	/**
	 * JPP设备统计参数
	 * 
	 **/
	private void makeParamsOfJPPVcl(StringBuffer firstDataHandlerSql,boolean existBTiming) {
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		String termSoftVer414 = EquipVersionCommon.getSoftVerByAgrType("Vcl_JPP");
		if(existBTiming){
			boolean exsitpgn = false;
			Map<String,Object> pgn = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_"+tableDate});
			Map<String,Object> pgnCont = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_Content_"+tableDate});
			if(null!=pgn && null!=pgnCont && MapGetter.getString(pgn, "counts").equals("1") && MapGetter.getString(pgnCont, "counts").equals("1")){
				exsitpgn = true;
			}
			StringBuffer strBuff414 = new StringBuffer();
			strBuff414.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons,MsgSTP_iIdleOil,MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,MsgSTP_tIdleOil,MsgSTP_StatTime) ");
			
			strBuff414.append("select VehicleID,CAST(round(convert(float,ISNULL(MsgT_tWorkTime_UDS-MsgT_tWorkTime_UDS_min,0))*1.0,2) as decimal(18,2)) as iEWorkHours, ");
			strBuff414.append("null as iETDistance,");
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tOilCons-MsgT_tOilCons_min,0))*1.0,2) as decimal(18,2)) as iOilCons, ");
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tIdleWorkTime_PGN-MsgT_tIdleWorkTime_PGN_min,0))*1.0,2) as decimal(18,2)) as iIdleOil, ");
			
			strBuff414.append("tEWorkHours=case when MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 then MsgT_tWorkTime_UDS else ISNULL(temp.MsgSTP_tEWorkHours,0) end, ");
			strBuff414.append("tETDistance=null,");
			strBuff414.append("tOilCons=case when MsgT_tOilCons is not null and MsgT_tOilCons>0 then MsgT_tOilCons else ISNULL(temp.MsgSTP_tOilCons,0) end, ");
			strBuff414.append("tIdleOil=case when MsgT_tIdleWorkTime_PGN is not null and MsgT_tIdleWorkTime_PGN>0 then MsgT_tIdleWorkTime_PGN else ISNULL(temp.MsgSTP_tIdleOil,0) end, ");
			
			strBuff414.append("?  ");
			strBuff414.append("from( select VehicleID, ");
			
			strBuff414.append("MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime desc), ");
			strBuff414.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 order by MsgT_MsgTime desc), ");
			strBuff414.append("MsgT_tIdleWorkTime_PGN = ISNULL((SELECT top 1 MsgT_tIdleWorkTime_PGN FROM CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" WHERE MsgT_Vcl_ID = VehicleID AND MsgT_tIdleWorkTime_PGN IS NOT NULL AND MsgT_tIdleWorkTime_PGN > 0 ORDER BY MsgT_MsgTime DESC), ");
			if(exsitpgn){
				//jiyongtian 20140819 怠速油耗取值逻辑调整
				strBuff414.append("ISNULL((select top 1 CONVERT(float,MsgPC_PGNValue) from  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID  where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and CONVERT(float,MsgPC_PGNValue)>0 and MsgP_Vcl_ID = VehicleID order by  MsgP_MsgTime desc ),0)), ");
//				strBuff414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MAX(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID  where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)), ");
			}else{
				strBuff414.append("0), ");
			}
			
			strBuff414.append("MsgT_tOilCons_min = case when (0=isnull(MsgSTP_tOilCons,0)) then (select top 1 MsgT_tOilCons from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime ) else MsgSTP_tOilCons end, ");
			strBuff414.append("MsgT_tWorkTime_UDS_min = case when (0=ISNULL(MsgSTP_tEWorkHours,0)) then (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 order by MsgT_MsgTime ) else MsgSTP_tEWorkHours end, ");
			strBuff414.append("MsgT_tIdleWorkTime_PGN_min = case when (0=isnull(mst.MsgSTP_tIdleOil,0)) then  isnull((SELECT   top 1  MsgT_tIdleWorkTime_PGN FROM CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" WHERE MsgT_Vcl_ID = VehicleID  AND MsgT_tIdleWorkTime_PGN IS NOT NULL  AND MsgT_tIdleWorkTime_PGN > 0 ORDER BY msgt_msgtime), ");
			if(exsitpgn){
				strBuff414.append("ISNULL((select top 1 CONVERT(float,MsgPC_PGNValue) from  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and CONVERT(float,MsgPC_PGNValue)>0 and MsgP_Vcl_ID = VehicleID order by  MsgP_MsgTime ),0)) ");
//				strBuff414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select min(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)) ");
			}else{
				strBuff414.append("0) ");
			}
			strBuff414.append("else mst.MsgSTP_tIdleOil end, ");
			
			strBuff414.append("MsgSTP_tOilCons,MsgSTP_tIdleOil,MsgSTP_tEWorkHours  ");
			
			
			strBuff414.append("from V_VehicleInfo left join( select * from Message_Stat_TimingParam where MsgSTP_StatTime = ?) mst on mst.MsgSTP_VclID = VehicleID " );
			strBuff414.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVer414.toString()+" ))temp  where 1=1 ");
			
			baseDAO.execInsert(strBuff414.toString(), new Object[]{this.thisWorkDay,this.lastWorkDay});
			
			
			/*已更新Message_Stat_TimingParam的方式录入jpp设备的四种里程**/
			StringBuffer update414 = new StringBuffer();
			update414.append("update Message_Stat_TimingParam set MsgSTP_iMeterDistance=temp.iMeterDis,MsgSTP_iRunKmExact=temp.iRunKmExact,MsgSTP_iRunKm=temp.iRunKm,MsgSTP_iRunKmECU=temp.iRunKmECU,");
			update414.append("MsgSTP_tMeterDistance=temp.tMeterDis,MsgSTP_tRunKmExact=temp.tRunKmExact,MsgSTP_tRunKm=temp.tRunKm,MsgSTP_tRunKmECU=temp.tRunKmECU  ");
			
			update414.append("from(select tmp.VehicleID, ");
			update414.append("CAST(round(convert(float,ISNULL(MsgT_tMeterDis-MsgT_tMeterDis_min,0))*1.0,2) as decimal(18,2)) as iMeterDis,");
			update414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmExact-MsgT_tRunKmExact_min,0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
			update414.append("CAST(round(convert(float,ISNULL(tRunKm-tRunKm_min,0))*1.0,2) as decimal(18,2)) as iRunKm,");
			update414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmECU-MsgT_tRunKmECU_min,0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
			
			update414.append("tMeterDis=case when MsgT_tMeterDis is not null and MsgT_tMeterDis>0 then MsgT_tMeterDis else ISNULL(tmp.MsgSTP_tMeterDistance,0) end, ");
			update414.append("tRunKmExact=case when MsgT_tRunKmExact is not null and MsgT_tRunKmExact>0 then MsgT_tRunKmExact else ISNULL(tmp.MsgSTP_tRunKmExact,0) end,");
			update414.append("tRunKm=case when tRunKm is not null and tRunKm>0 then tRunKm else ISNULL(tmp.MsgSTP_tRunKm,0) end,");
			update414.append("tRunKmECU=case when MsgT_tRunKmECU is not null and MsgT_tRunKmECU>0 then MsgT_tRunKmECU else ISNULL(tmp.MsgSTP_tRunKmECU,0) end  ");
			
			update414.append("from (select vv.VehicleID,");
			update414.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by  MsgT_MsgTime desc) , ");
			update414.append("MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by  MsgT_MsgTime desc),");
			update414.append("tRunKm = (select top 1 MsgT_tRunKm from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by  MsgT_MsgTime desc),");
			update414.append("MsgT_tMeterDis = ISNULL((select top 1 MsgT_tRunKmExact_PGN from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 order by MsgT_MsgTime desc),");
			if(exsitpgn){
//				调整JPP设备仪表里程 参数信息取值逻辑调整，jiyongtian 20140815 cty 1688
//				update414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MAX(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where  MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)),");
				update414.append("ISNULL((select top 1 CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID = MsgPC_MsgP_ID where MsgP_Vcl_ID = VehicleID and MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and CONVERT(float,MsgPC_PGNValue)>0 order by MsgP_MsgTime desc),0)),");
			}else{
				update414.append("0),");
			}
			
			update414.append("MsgT_tRunKmECU_min = case when (0=isnull(mst.MsgSTP_tRunKmECU,0)) then (select top 1 MsgT_tRunKmECU from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by  MsgT_MsgTime) " +
					"else mst.MsgSTP_tRunKmECU end, ");
			update414.append("MsgT_tRunKmExact_min = case when (0=isnull(mst.MsgSTP_tRunKmExact,0)) then (select top 1 MsgT_tRunKmExact from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by  MsgT_MsgTime) " +
					"else mst.MsgSTP_tRunKmExact end,");
			update414.append("tRunKm_min = case when (0=isnull(mst.MsgSTP_tRunKm,0)) then (select top 1 MsgT_tRunKm from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by  MsgT_MsgTime) " +
					"else mst.MsgSTP_tRunKm end,");
			update414.append("MsgT_tMeterDis_min = case when (0=isnull(mst.MsgSTP_tMeterDistance,0)) then ISNULL((select top 1 MsgT_tRunKmExact_PGN from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 order by MsgT_MsgTime),");
			if(exsitpgn){
//				update414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MIN(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where  MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)) ");
				update414.append("ISNULL((select top 1 CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID = MsgPC_MsgP_ID where MsgP_Vcl_ID = VehicleID and MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and CONVERT(float,MsgPC_PGNValue)>0 order by MsgP_MsgTime),0)) ");
			}else{
				update414.append("0) ");
			}
			update414.append("else mst.MsgSTP_tMeterDistance end,");
			update414.append("mst.MsgSTP_tMeterDistance,mst.MsgSTP_tRunKmExact,mst.MsgSTP_tRunKm,mst.MsgSTP_tRunKmECU  ");
			update414.append("from V_VehicleInfo vv left join (select * from Message_Stat_TimingParam where MsgSTP_StatTime = ? ) mst on mst.MsgSTP_VclID = VehicleID  ");
			update414.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVer414.toString()+" ) ");
			update414.append(")tmp )temp where MsgSTP_StatTime = ? and temp.VehicleID = MsgSTP_VclID ");
			baseDAO.execUpdate(update414.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});
			
			/*已更新Message_Stat_TimingParam的方式录入怠速耗油量**/
		/*	StringBuffer updateOil414 = new StringBuffer();
			updateOil414.append("update Message_Stat_TimingParam set MsgSTP_iIdleOil=tempp.iIdleOil,MsgSTP_tIdleOil=tempp.tIdleOil ");
			updateOil414.append("from(select tIdleOil = " +
					"CASE WHEN msgt_tidleworktime_pgn IS NOT NULL AND msgt_tidleworktime_pgn > 0 THEN msgt_tidleworktime_pgn  ");
			updateOil414.append("else (case when msgt_tidleworktime_pgnParm IS NOT NULL AND msgt_tidleworktime_pgnParm > 0 THEN msgt_tidleworktime_pgnParm ");
			updateOil414.append("else  ISNULL(temp.MsgSTP_tIdleOil,0) end)  END , ");
			updateOil414.append("iIdleOil = case when (Cast(Round(Convert(FLOAT,Isnull(msgt_tidleworktime_pgn - msgt_tidleworktime_pgn_min,0)) * 1.0, 2) AS DECIMAL(18,2)))IS NULL ");
			updateOil414.append("then (Cast(Round(Convert(FLOAT,Isnull(msgt_tidleworktime_pgnParm - msgt_tidleworktime_pgnParm_min,0)) * 1.0,2) AS DECIMAL(18,2))) else ");
			updateOil414.append("(Cast(Round(Convert(FLOAT,Isnull(msgt_tidleworktime_pgn - msgt_tidleworktime_pgn_min,0)) * 1.0,2) AS DECIMAL(18,2))) end ");
			updateOil414.append(",VehicleID from ( select VehicleID, MsgSTP_tOilCons,MsgSTP_tIdleOil," +
					"msgt_tidleworktime_pgn = (SELECT top 1 msgt_tidleworktime_pgn FROM cty_egn_b.dbo.msg_timing_"+tableDate+" WHERE msgt_vcl_id = vehicleid  ");
			updateOil414.append("AND msgt_tidleworktime_pgn IS NOT NULL AND msgt_tidleworktime_pgn > 0 ORDER BY msgt_msgtime DESC),");
			updateOil414.append("msgt_tidleworktime_pgn_min = (SELECT   top 1  msgt_tidleworktime_pgn FROM cty_egn_b.dbo.msg_timing_"+tableDate+" WHERE msgt_vcl_id = vehicleid  AND msgt_tidleworktime_pgn IS NOT NULL  AND msgt_tidleworktime_pgn > 0 ORDER BY msgt_msgtime), ");
			updateOil414.append("msgt_tidleworktime_pgnParm = ISNULL((select CONVERT(float,MsgPC_PGNValue) from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MAX(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID " +
					" where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = vehicleid)),0), ");
			updateOil414.append("msgt_tidleworktime_pgnParm_min =  ISNULL((select CONVERT(float,MsgPC_PGNValue) from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select min(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID " +
					" where MsgPC_SysPIP_ID=11 and MsgPC_SysPI_ID=8 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = vehicleid)),0) ");
			updateOil414.append("from V_VehicleInfo left join( select * from Message_Stat_TimingParam where MsgSTP_StatTime = ?) mst on mst.MsgSTP_VclID = VehicleID where UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVer414.toString()+"))temp  where 1=1)tempp ");
			updateOil414.append("where MsgSTP_StatTime = ? and tempp.VehicleID = MsgSTP_VclID");
			baseDAO.execUpdate(updateOil414.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});*/
		}else{
			String workSQL414 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+termSoftVer414+")";
			baseDAO.execInsert(workSQL414, new Object[]{this.thisWorkDay});
		}
	}
	/**
	 * JPP设备统计参数
	 * 
	 **/
	private void makeParamsOfJPPVcl_bak(StringBuffer firstDataHandlerSql,boolean existBTiming) {
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		String termSoftVer414 = EquipVersionCommon.spltSoftVer(EquipVersionCommon.getSoftVerByAgrType("414"),EquipVersionCommon.getSoftVerByAgrType("418"),EquipVersionCommon.getSoftVerByAgrType("420"),EquipVersionCommon.getSoftVerByAgrType("423"),EquipVersionCommon.getSoftVerByAgrType("424"));
		if(existBTiming){
			boolean exsitpgn = false;
			Map<String,Object> pgn = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_"+tableDate});
			Map<String,Object> pgnCont = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_Content_"+tableDate});
			if(null!=pgn && null!=pgnCont && MapGetter.getString(pgn, "counts").equals("1") && MapGetter.getString(pgnCont, "counts").equals("1")){
				exsitpgn = true;
			}
			StringBuffer strBuff414 = new StringBuffer();
			//update Message_Stat_TimingParam set MsgSTP_iMeterDistance=?,MsgSTP_iRunKmExact=?,MsgSTP_iRunKm=?,MsgSTP_iRunKmECU=?,MsgSTP_tMeterDistance=?,MsgSTP_tRunKmExact=?,MsgSTP_tRunKm=?,MsgSTP_tRunKmECU=?
			strBuff414.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons," +
					"MsgSTP_iMeterDistance,MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU," +
					                                                             "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons," +
					"MsgSTP_tMeterDistance,MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
			
			strBuff414.append("select VehicleID,CAST(round(convert(float,ISNULL(MsgT_tWorkTime_UDS-" +
					"(select case when 0=ISNULL(MsgSTP_tEWorkHours,0) then (select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 order by MsgT_MsgTime) else MsgSTP_tEWorkHours end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			/*		"case(ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tWorkTime_UDS) else (select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKm-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKm),0))*1.0,2) as decimal(18,2)) as iETDistance,");*/
			
			strBuff414.append("null as iETDistance,");
			
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tOilCons-" +
					"(select case when 0=ISNULL(MsgSTP_tOilCons,0) then (select top 1 MsgT_tOilCons from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime) else MsgSTP_tOilCons end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iOilCons,");
			
			/*		"case(ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tOilCons) else (select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iOilCons,");*/
			
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tMeterDis-" +
					"(select case when 0=ISNULL(MsgSTP_tMeterDistance,0) then ");
			strBuff414.append("ISNULL((select top 1 MsgT_tRunKmExact_PGN from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" " +
					"where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 order by MsgT_MsgTime),");
			if(exsitpgn){
				strBuff414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MIN(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where  MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)) ");
			}else{
				strBuff414.append("0) ");
			}
			strBuff414.append(" else MsgSTP_tMeterDistance end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iMeterDis,");
			
			/*		"case(ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tMeterDis) else (select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iMeterDis,");*/
			
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmExact-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKmExact,0) then (select top 1 MsgT_tRunKmExact from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by MsgT_MsgTime) " +
							"else MsgSTP_tRunKmExact end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
					",0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
			
			/*		"case(ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tRunKmExact) else (select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmExact,");*/
			
			strBuff414.append("CAST(round(convert(float,ISNULL(tRunKm-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKm,0) then (select top 1 MsgT_tRunKm from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by MsgT_MsgTime) " +
					"else MsgSTP_tRunKm end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
			        ",0))*1.0,2) as decimal(18,2)) as iRunKm,");
			/*      "case(ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+tRunKm) else (select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKm,");*/
			
			strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmECU-" +
					"(select case when 0=ISNULL(MsgSTP_tRunKmECU,0) then (select top 1 MsgT_tRunKmECU from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by MsgT_MsgTime) " +
					"else MsgSTP_tRunKmECU end from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime= ? )"+
			        ",0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
			
			/*		"case(ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
			strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),0)) when 0 then (999999999+MsgT_tRunKmECU) else (select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?) end,0))*1.0,2) as decimal(18,2)) as iRunKmECU,");*/
			
			strBuff414.append("tEWorkHours=case when MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 then MsgT_tWorkTime_UDS else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
//			strBuff414.append("tETDistance=case when MsgT_tRunKm is not null and MsgT_tRunKm>0 then MsgT_tRunKm else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			strBuff414.append("tETDistance=null,");
			strBuff414.append("tOilCons=case when MsgT_tOilCons is not null and MsgT_tOilCons>0 then MsgT_tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			
			strBuff414.append("tMeterDis=case when MsgT_tMeterDis is not null and MsgT_tMeterDis>0 then MsgT_tMeterDis else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end, ");
			strBuff414.append("tRunKmExact=case when MsgT_tRunKmExact is not null and MsgT_tRunKmExact>0 then MsgT_tRunKmExact else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			strBuff414.append("tRunKm=case when tRunKm is not null and tRunKm>0 then tRunKm else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			strBuff414.append("tRunKmECU=case when MsgT_tRunKmECU is not null and MsgT_tRunKmECU>0 then MsgT_tRunKmECU else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
			
			strBuff414.append("? ");
			strBuff414.append("from( select VehicleID,");
//					"MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm when MsgT_tRunKm is null and MsgT_tRunKmExact is not null then MsgT_tRunKmExact else ISNULL(MsgT_tRunKmECU,0) end,");
			
			strBuff414.append("MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime desc),");
			strBuff414.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 order by MsgT_MsgTime desc),");
			
			strBuff414.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by  MsgT_MsgTime desc),");
			strBuff414.append("MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by  MsgT_MsgTime desc),");
			strBuff414.append("tRunKm = (select top 1 MsgT_tRunKm from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by  MsgT_MsgTime desc),");
			strBuff414.append("MsgT_tMeterDis = ISNULL((select top 1 MsgT_tRunKmExact_PGN from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 order by MsgT_MsgTime desc),");
			if(exsitpgn){
				strBuff414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MAX(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where  MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)) ");
			}else{
				strBuff414.append("0) ");
			}
			
			strBuff414.append("from V_VehicleInfo " );
//					"left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+"  on VehicleID = MsgT_Vcl_ID and MsgT_ID in (");
//			strBuff414.append("select MAX(MsgT_ID)  as msgID from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where (MsgT_tRunKm is not null or MsgT_tRunKmExact is not null or MsgT_tRunKmECU is not null) and (MsgT_tRunKm >0 or MsgT_tRunKmExact >0 or MsgT_tRunKmECU >0) group by MsgT_Vcl_ID) ");
			strBuff414.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVer414.toString()+" ))temp  where 1=1 ");
			
			baseDAO.execInsert(strBuff414.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
			
			//获取jpp设备
//			String querySQL = "select VehicleID,MsgSTP_ID from V_VehicleInfo vv inner join Message_Stat_TimingParam mst on mst.MsgSTP_VclID = VehicleID where MsgSTP_StatTime = '"+this.thisWorkDay+"' and Tmnl_SoftEdition in("+termSoftVer414.toString()+")";
//			List<Map<String,Object>> vclList414 = this.baseDAO.execQuery(querySQL, new Object[]{});
//			
//			boolean exsitpgn = false;
//			Map<String,Object> pgn = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_"+tableDate});
//			Map<String,Object> pgnCont = this.baseDAO.execQueryOne(this.checkTable, new Object[]{"Msg_PGN_Content_"+tableDate});
//			if(null!=pgn && null!=pgnCont && MapGetter.getString(pgn, "counts").equals("1") && MapGetter.getString(pgnCont, "counts").equals("1")){
//				exsitpgn = true;
//			}
//			//仪表里程、高精度里程、ecm里程、ecu里程 处理
//			if(null!=vclList414&&vclList414.size()>0){
//				String vclID;
//				String msgstpID;
//				
//				StringBuffer query414 = new StringBuffer();
//				query414.append("select CAST(round(convert(float,ISNULL(MsgT_tRunKmExact-ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
//				query414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKmExact),0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
//				
//				query414.append("CAST(round(convert(float,ISNULL(tRunKm-ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
//				query414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tRunKm),0))*1.0,2) as decimal(18,2)) as iRunKm,");
//				
//				query414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmECU-ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
//				query414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKmECU),0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
//				
//				query414.append("CAST(round(convert(float,ISNULL(MsgT_tMeterDis-ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
//				query414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tMeterDis),0))*1.0,2) as decimal(18,2)) as iMeterDis,");
//				
//				query414.append("tMeterDis=case when MsgT_tMeterDis is not null and MsgT_tMeterDis>0 then MsgT_tMeterDis else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end, ");
//				query414.append("tRunKmExact=case when MsgT_tRunKmExact is not null and MsgT_tRunKmExact>0 then MsgT_tRunKmExact else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
//				query414.append("tRunKm=case when tRunKm is not null and tRunKm>0 then tRunKm else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
//				query414.append("tRunKmECU=case when MsgT_tRunKmECU is not null and MsgT_tRunKmECU>0 then MsgT_tRunKmECU else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end ");
//				
//				query414.append("from (select VehicleID,MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by  MsgT_MsgTime desc),");
//				query414.append("MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by  MsgT_MsgTime desc),");
//				query414.append("tRunKm = (select top 1 MsgT_tRunKm from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by  MsgT_MsgTime desc),");
//				query414.append("MsgT_tMeterDis = ISNULL((select top 1 MsgT_tRunKmExact_PGN from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 order by MsgT_MsgTime desc),");
//				if(exsitpgn){
//					query414.append("ISNULL((select CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis from CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" where MsgPC_ID = (select MAX(MsgPC_ID) from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID where  MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID = VehicleID)),0)) ");
//				}else{
//					query414.append("0)");
//				}
//				query414.append("from V_VehicleInfo where VehicleID = ? )tmp where 1=1 ");
//				
//				/*this.thisUpdateSQLList = new ArrayList<String>();
//				this.thisUpdateParamList = new ArrayList<Object[]>();*/
//				String updateSQL = "update Message_Stat_TimingParam set MsgSTP_iMeterDistance=?,MsgSTP_iRunKmExact=?,MsgSTP_iRunKm=?,MsgSTP_iRunKmECU=?,MsgSTP_tMeterDistance=?,MsgSTP_tRunKmExact=?,MsgSTP_tRunKm=?,MsgSTP_tRunKmECU=? where MsgSTP_ID = ?";
//				for(Map<String,Object> one414:vclList414){
//					vclID = MapGetter.getString(one414, "VehicleID");
//					System.out.println("设备ID是："+vclID);
//					msgstpID = MapGetter.getString(one414, "MsgSTP_ID");
//					Map<String,Object> mapKM = this.baseDAO.execQueryOne(query414.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,this.lastWorkDay,vclID}); 
//					/*this.thisUpdateSQLList.add(updateSQL);
//					this.thisUpdateParamList.add(new Object[]{
//							MapGetter.getString(mapKM,"iMeterDis"),
//							MapGetter.getString(mapKM,"iRunKmExact"),
//							MapGetter.getString(mapKM,"iRunKm"),
//							MapGetter.getString(mapKM,"iRunKmECU"),
//							MapGetter.getString(mapKM,"tMeterDis"),
//							MapGetter.getString(mapKM,"tRunKmExact"),
//							MapGetter.getString(mapKM,"tRunKm"),
//							MapGetter.getString(mapKM,"tRunKmECU"),
//							msgstpID
//					});*/
//					this.baseDAO.execUpdate(updateSQL, new Object[]{MapGetter.getString(mapKM,"iMeterDis"),
//							MapGetter.getString(mapKM,"iRunKmExact"),
//							MapGetter.getString(mapKM,"iRunKm"),
//							MapGetter.getString(mapKM,"iRunKmECU"),
//							MapGetter.getString(mapKM,"tMeterDis"),
//							MapGetter.getString(mapKM,"tRunKmExact"),
//							MapGetter.getString(mapKM,"tRunKm"),
//							MapGetter.getString(mapKM,"tRunKmECU"),
//							msgstpID});
//				}
//				/*if(this.thisUpdateSQLList.size()>0){
//					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
//					this.thisUpdateSQLList = null; 
//					this.thisUpdateParamList = null;
//				}*/
//			}
			//当天安装的jpp设备处理
			List<Map<String,Object>> firstDataHandlerList414 = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+termSoftVer414.toString()+")", new Object[]{});
			if(null!=firstDataHandlerList414&&firstDataHandlerList414.size()>0){//存在当天安装的jpp设备					
				StringBuffer paramKmSqlSub = new StringBuffer();//查询油耗、工作小时数、高精度里程、ecm里程
				paramKmSqlSub.append("select tmp.MsgT_tOilCons-tmp1.MsgT_tOilCons iOil,tmp.MsgT_tWorkTime_UDS-tmp1.MsgT_tWorkTime_UDS iTime,");						
				paramKmSqlSub.append("tmp.MsgT_tRunKmExact-tmp1.MsgT_tRunKmExact iRunKmExact,tmp.tRunKm-tmp1.tRunKm iRunKm ");
				paramKmSqlSub.append("from (select MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tOilCons is not null and MsgT_tOilCons >0  order by MsgT_MsgTime desc),");
				paramKmSqlSub.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0  order by MsgT_MsgTime desc), ");
				paramKmSqlSub.append("MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0  order by MsgT_MsgTime desc),");
				paramKmSqlSub.append("tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKm is not null and MsgT_tRunKm >0  order by MsgT_MsgTime desc) ");
				paramKmSqlSub.append(" from V_VehicleInfo where VehicleID = ?)tmp left join (select ");
				paramKmSqlSub.append("MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tOilCons is not null and MsgT_tOilCons >0  order by MsgT_MsgTime ASC),");
				paramKmSqlSub.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0  order by MsgT_MsgTime ASC),");
				paramKmSqlSub.append("MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0  order by MsgT_MsgTime asc),");
				paramKmSqlSub.append("tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKm is not null and MsgT_tRunKm >0  order by MsgT_MsgTime asc) ");
				paramKmSqlSub.append(" from V_VehicleInfo where VehicleID = ? )tmp1 on 1=1 where 1=1 ");
				
				StringBuffer paramKmSqlElse = new StringBuffer();//查询里程（优先级）、ecu里程、仪表里程
				paramKmSqlElse.append("select tmp.MsgT_tRunKm-tmp1.MsgT_tRunKm iKm,tmp.MsgT_tRunKmECU-tmp1.MsgT_tRunKmECU iRunKmECU, tmp.MsgT_tRunKmExact_PGN-tmp1.MsgT_tRunKmExact_PGN iRunKmExact_PGN ");
				paramKmSqlElse.append("from (select MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm when MsgT_tRunKm is null and MsgT_tRunKmExact is not null then MsgT_tRunKmExact else ISNULL(MsgT_tRunKmECU,0) end, ");
				paramKmSqlElse.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU  from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0  order by MsgT_MsgTime desc),");
				paramKmSqlElse.append("MsgT_tRunKmExact_PGN = case when MsgT_tRunKmExact_PGN IS not null and MsgT_tRunKmExact_PGN >0 then MsgT_tRunKmExact_PGN ");
				if(exsitpgn){
					paramKmSqlElse.append("else ISNULL(MsgP_tMeterDis,0) end ");
				}else{
					paramKmSqlElse.append("else 0 end ");
				}
				paramKmSqlElse.append("from V_VehicleInfo left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID= MsgT_Vcl_ID and MsgT_ID in (select MAX(MsgT_ID) from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmExact_PGN is not null group by MsgT_Vcl_ID) ");
				if(exsitpgn){
					paramKmSqlElse.append("left join ( SELECT MsgP_Vcl_ID, Convert(FLOAT,MsgPC_PGNValue) AS MsgP_tMeterDis FROM  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" ON MsgP_ID = MsgPC_MsgP_ID and MsgPC_ID in ( SELECT Max(MsgPC_ID) MsgPC_ID  From CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgPC_MsgP_ID = MsgP_ID WHERE MsgPC_SysPIP_ID = 405 AND MsgPC_SysPI_ID = 65 AND MsgPC_PGNValue IS NOT NULL  GROUP BY MsgP_Vcl_ID))temp_meter on temp_meter.MsgP_Vcl_ID = VehicleID ");
				}
				paramKmSqlElse.append("where VehicleID = ?)tmp left join (select top 1 MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm when MsgT_tRunKm is null and MsgT_tRunKmExact is not null then MsgT_tRunKmExact else ISNULL(MsgT_tRunKmECU,0) end, ");
				paramKmSqlElse.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU  from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0  order by MsgT_MsgTime asc),");
				paramKmSqlElse.append("MsgT_tRunKmExact_PGN = case when MsgT_tRunKmExact_PGN IS not null and MsgT_tRunKmExact_PGN >0 then MsgT_tRunKmExact_PGN ");
				if(exsitpgn){
					paramKmSqlElse.append("else ISNULL(MsgP_tMeterDis,0) end ");
				}else{
					paramKmSqlElse.append("else 0 end ");
				}
				paramKmSqlElse.append("from V_VehicleInfo left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID=MsgT_Vcl_ID and MsgT_ID in (select MIN(MsgT_ID) from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN>0 group by MsgT_Vcl_ID) ");
				if(exsitpgn){
					paramKmSqlElse.append("left join ( SELECT MsgP_Vcl_ID, Convert(FLOAT,MsgPC_PGNValue) AS MsgP_tMeterDis FROM  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" ON MsgP_ID = MsgPC_MsgP_ID and MsgPC_ID in ( SELECT Min(MsgPC_ID) MsgPC_ID  From CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgPC_MsgP_ID = MsgP_ID WHERE MsgPC_SysPIP_ID = 405 AND MsgPC_SysPI_ID = 65 AND MsgPC_PGNValue IS NOT NULL  GROUP BY MsgP_Vcl_ID))temp_meter on temp_meter.MsgP_Vcl_ID = VehicleID ");
				}
				paramKmSqlElse.append("where VehicleID = ? )tmp1 on 1=1 where 1=1 ");
								
				this.thisUpdateSQLList = new ArrayList<String>();
				this.thisUpdateParamList = new ArrayList<Object[]>();
				for(Map<String,Object> vcl414:firstDataHandlerList414){
					String VclID = MapGetter.getString(vcl414, "MsgSTP_VclID");
					Map<String,Object> paramMapSub = baseDAO.execQueryOne(paramKmSqlSub.toString(), new Object[]{VclID,VclID});
					Map<String,Object> paramMapElse = baseDAO.execQueryOne(paramKmSqlElse.toString(), new Object[]{VclID,VclID});
					this.thisUpdateSQLList.add(this.thisUpdateFirst.toString());
					this.thisUpdateParamList.add(new Object[]{this.getFloat(paramMapSub, "iOil"),this.getFloat(paramMapElse, "iKm"),this.getFloat(paramMapSub, "iTime"),this.getFloat(paramMapElse, "iRunKmExact_PGN"),
							this.getFloat(paramMapSub, "iRunKmExact"),this.getFloat(paramMapSub, "iRunKm"),this.getFloat(paramMapElse, "iRunKmECU"),
							MapGetter.getString(vcl414, "MsgSTP_ID")});
//					this.baseDAO.execUpdate(this.thisUpdateFirst.toString(), new Object[]{
//						this.getFloat(paramMapSub, "iOil"),this.getFloat(paramMapElse, "iKm"),this.getFloat(paramMapSub, "iTime"),this.getFloat(paramMapElse, "iRunKmExact_PGN"),
//								this.getFloat(paramMapSub, "iRunKmExact"),this.getFloat(paramMapSub, "iRunKm"),this.getFloat(paramMapElse, "iRunKmECU"),
//								MapGetter.getString(vcl414, "MsgSTP_ID")
//					});
				}
				if(this.thisUpdateSQLList.size()>0){
					tranDAO.batch(this.thisUpdateSQLList, this.thisUpdateParamList);
					this.thisUpdateSQLList = null; 
					this.thisUpdateParamList = null;
				}
			}
		}else{
			String workSQL414 = this.nullInsertSQL.toString()+" and Tmnl_SoftEdition in ("+termSoftVer414+")";
			baseDAO.execInsert(workSQL414, new Object[]{this.thisWorkDay});
		}
	}
	/**
	 * 初始化：无源数据表时的录入语句和  当天安装的设备的更新语句
	 **/
	private void Init() {
		this.nullInsertSQL = new StringBuffer();
		this.nullInsertSQL.append("insert into Message_Stat_TimingParam");
		this.nullInsertSQL.append("(MsgSTP_VclID,MsgSTP_iETDistance,MsgSTP_iEWorkHours,MsgSTP_iOilCons,MsgSTP_iIdleOil,MsgSTP_iRunKmExact,");
		this.nullInsertSQL.append("MsgSTP_iRunKm,MsgSTP_iRunKmECU,MsgSTP_tETDistance," +
				"MsgSTP_tEWorkHours,MsgSTP_tOilCons,MsgSTP_tIdleOil,MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
		this.nullInsertSQL.append("select VehicleID,MsgSTP_iETDistance,");
		this.nullInsertSQL.append("MsgSTP_iEWorkHours,MsgSTP_iOilCons,MsgSTP_iIdleOil,MsgSTP_iRunKmExact,MsgSTP_iRunKm,");
		this.nullInsertSQL.append("MsgSTP_iRunKmECU,MsgSTP_tETDistance,MsgSTP_tEWorkHours,MsgSTP_tOilCons,MsgSTP_tIdleOil,");
		this.nullInsertSQL.append("MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,? from V_VehicleInfo ");
		this.nullInsertSQL.append("left join Message_Stat_TimingParam on VehicleID=MsgSTP_VclID and MsgSTP_StatTime='"+this.lastWorkDay+"' ");
		this.nullInsertSQL.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition is not null and Tmnl_SoftEdition<>'' ");
		
		this.thisUpdateFirst = new StringBuffer();
		this.thisUpdateFirst.append("update Message_Stat_TimingParam set MsgSTP_iOilCons=?,MsgSTP_iIdleOil=?,MsgSTP_iETDistance=?,MsgSTP_iEWorkHours=?,MsgSTP_iMeterDistance=? " +
				",MsgSTP_iRunKmExact=?,MsgSTP_iRunKm=?,MsgSTP_iRunKmECU=? where MsgSTP_ID=?");
	}
	/**
	 * 统计设备参数信息
	 * 更新历史：jiyongtian2014-03-25 增加“当日ECM高精度总里程”“累计ECM高精度总里程”“当日ECM总里程”“累计ECM总里程”“当日ECU总里程”
	 * jiyongtian20140410变更逻辑
	 * jiyongtian20140504进行了重构，逻辑不变
	 */
	public void startStat(){		
		System.out.print("统计设备参数信息：["+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss")+"~");		
		//获取已统计的最后日期
		String tableLastTime = this.getLastDateTime();
		//jiyongtian 20140426 如果昨天的数据已经执行过了，则直接返回。
		if(tableLastTime.equals(DateUtil.addDay(-1))){
			System.out.println("统计设备参数信息已经执行过了，故这次直接返回："+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
			return ;
		}
		
		this.lastWorkDay = !"".equals(tableLastTime)?tableLastTime:DateUtil.addDay(-2);
		this.thisWorkDay = DateUtil.addDay(-1);
		
		this.Init();
		//校验表是否存在初始化为大一设备的校验SQL
		this.checkTable = "select count(1) as counts from CTY_Egn_A.dbo.SysObjects Where XType='U' and Name=?";
		//大一设备统计参数
		this.makeParamsOfBoVcl();
		System.out.println("大一设备参数统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		//校验表是否存在初始化为小一设备的校验SQL
		this.checkTable = "select count(1) as counts from CTY_Egn_B.dbo.SysObjects Where XType='U' and Name=?";
		//当天安装小一设备 校验sql
		StringBuffer firstDataHandlerSql = new StringBuffer("select * from Message_Stat_TimingParam ");
		firstDataHandlerSql.append("left join V_VehicleInfo on MsgSTP_VclID=VehicleID where MsgSTP_StatTime='"+this.thisWorkDay+"' " +
				"and (MsgSTP_iOilCons=-999999999  or MsgSTP_iEWorkHours=-999999999 or MsgSTP_iMeterDistance=-999999999" +
				"or MsgSTP_iRunKmExact=-999999999 or MsgSTP_iRunKm=-999999999 or MsgSTP_iRunKmECU=-999999999 ) ");
		
		//403设备统计参数
		this.makeParamsOfBoCanVcl(firstDataHandlerSql);
		System.out.println("小一J设备参数统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		//校验B库定时表是否存在
		String tableDate = this.thisWorkDay.replace("-", "");
		boolean existBTiming = false;
		Map<String,Object> msgTimingB = this.baseDAO.execQueryOne(checkTable, new Object[]{"Msg_Timing_"+tableDate+""});
		if(null!=msgTimingB &&MapGetter.getString(msgTimingB, "counts").equals("1")){
			existBTiming = true;
		}
		//2014-12-08 去掉PP参数的统计 3.6.6.2 fujichuan
//		this.makeParamsOfPPVcl(firstDataHandlerSql,existBTiming);
//		System.out.println("小一pp设备参数统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		this.makeParamsOfJPPVcl(firstDataHandlerSql,existBTiming);
		System.out.println("小一jpp设备参数统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));	
		this.updateGPSDistancenew();//jiyongtian 20141016 gps里程计算采用新逻辑
		System.out.println("GPS里程统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		this.updateVclIdleSpeedTime();
		System.out.println("设备怠速时长统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		this.updateVclUreo();
		System.out.println("设备尿素消耗量统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		this.updateVclAvgLoad();
		System.out.println("设备平均载重统计完成"+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
		//当天值负数统一处理
		List<String> sqlList = new ArrayList<String>();
		String iETDistance = "update Message_Stat_TimingParam set MsgSTP_iETDistance=0 where MsgSTP_iETDistance<0;";
		String iOilCons = "update Message_Stat_TimingParam set MsgSTP_iOilCons=0 where MsgSTP_iOilCons<0;";
		String iEWorkHours = "update Message_Stat_TimingParam set MsgSTP_iEWorkHours=0 where MsgSTP_iEWorkHours<0;";
		//增加仪表里程当天值负数处理
		String iMeterDistance = "update Message_Stat_TimingParam set MsgSTP_iMeterDistance=0 where MsgSTP_iMeterDistance<0;";
		String iRunKmExact = "update Message_Stat_TimingParam set MsgSTP_iRunKmExact=0 where MsgSTP_iRunKmExact<0;";
		String iRunKm = "update Message_Stat_TimingParam set MsgSTP_iRunKm=0 where MsgSTP_iRunKm<0;";
		String iRunKmECU = "update Message_Stat_TimingParam set MsgSTP_iRunKmECU=0 where MsgSTP_iRunKmECU<0;";
		String iRunKmGPS = "update Message_Stat_TimingParam set MsgSTP_iGPSDistance=0 where MsgSTP_iGPSDistance<0;";
		String iIdleTime = "update Message_Stat_TimingParam set MsgSTP_iIdleTime=0 where MsgSTP_iIdleTime<0;";
		String iUraeValue = "update Message_Stat_TimingParam set MsgSTP_iUraeValue=0 where MsgSTP_iUraeValue<0;";
		String iIdleOil = "update Message_Stat_TimingParam set MsgSTP_iIdleOil=0 where MsgSTP_iIdleOil<0;";
		sqlList.add(iETDistance);
		sqlList.add(iOilCons);
		sqlList.add(iEWorkHours);
		sqlList.add(iMeterDistance);
		sqlList.add(iRunKmExact);
		sqlList.add(iRunKm);
		sqlList.add(iRunKmECU);
		sqlList.add(iRunKmGPS);
		sqlList.add(iIdleTime);
		sqlList.add(iUraeValue);
		sqlList.add(iIdleOil);
		tranDAO.batch(sqlList);
		//GPS里程更新
		//this.updateGPSDistance(tableDate);
		System.out.println(DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss")+"]，统计的数据日期："+DateUtil.addDay(-1));
		
		/*
		System.out.print("统计设备参数信息：["+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss")+"~");
		//获得昨天的日期字符串，格式yyyyMMdd
		String tableDate = DateUtil.addDay(-1).replace("-", "");
		//jiyongtian 20140426 如果昨天的数据已经执行过了，则直接返回。
		String tableLastTime = this.getLastDateTime();
		if(tableLastTime.equals(DateUtil.addDay(-1))){
			System.out.println("统计设备参数信息已经执行过了，故这次直接返回："+DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss"));
			return ;
		}
		//获取统计表中最后一次统计的数据日期
		//String lastTime = !"".equals(this.getLastDateTime())?this.getLastDateTime():DateUtil.addDay(-2);
		String lastTime = !"".equals(tableLastTime)?tableLastTime:DateUtil.addDay(-2);
		
		//检验日增表是否存在
		//1.大一_定时参数信息
		String strSQL_A = "select count(1) as counts from CTY_Egn_A.dbo.SysObjects Where XType='U' and Name=?";
		Map<String,Object> map_c = baseDAO.execQueryOne(strSQL_A, new Object[]{"Msg_Timing_"+tableDate+""});
		//2.小一_CAN总线信息
		String strSQL_B = "select count(1) as counts from CTY_Egn_B.dbo.SysObjects Where XType='U' and Name=?";
		Map<String,Object> msgCan = baseDAO.execQueryOne(strSQL_B, new Object[]{"Msg_CAN_Content_"+tableDate+""});
		//3.小一_定时位置信息
		Map<String,Object> msgT = baseDAO.execQueryOne(strSQL_B, new Object[]{"Msg_Timing_"+tableDate+""});
		//4.小一_412
		Map<String,Object> msgU = baseDAO.execQueryOne(strSQL_B, new Object[]{"Msg_UDS_"+tableDate});
		//4.小一_414
		Map<String,Object> msgP = baseDAO.execQueryOne(strSQL_B, new Object[]{"Msg_PGN_"+tableDate});
		
		//更新初次统计的设备  主要是JPP设备、j设备
		String firstDataHandlerSql = "select * from Message_Stat_TimingParam " +
				"left join V_VehicleInfo on MsgSTP_VclID=VehicleID " +
				"where MsgSTP_StatTime='"+DateUtil.addDay(-1)+"' " +
				"and (MsgSTP_iOilCons=-999999999 or MsgSTP_iETDistance=-999999999 or MsgSTP_iEWorkHours=-999999999 or MsgSTP_iMeterDistance=-999999999" +
				"or MsgSTP_iRunKmExact=-999999999 or MsgSTP_iRunKm=-999999999 or MsgSTP_iRunKmECU=-999999999 ) ";
		//大一设备 初次统计 
		String firstDataHandlerSqlBo = "select * from Message_Stat_TimingParam " +
				"left join V_VehicleInfo on MsgSTP_VclID=VehicleID " +
				"where MsgSTP_StatTime='"+DateUtil.addDay(-1)+"' " +
				"and (MsgSTP_iOilCons=-999999999 or MsgSTP_iETDistance=-999999999 or MsgSTP_iEWorkHours=-999999999 " +
				"or MsgSTP_iRunKmExact=-999999999 or MsgSTP_iRunKm=-999999999 or MsgSTP_iRunKmECU=-999999999 ) ";
		//412设备
		String firstDataHandlerSql412 = "select * from Message_Stat_TimingParam " +
				"left join V_VehicleInfo on MsgSTP_VclID=VehicleID " +
				"where MsgSTP_StatTime='"+DateUtil.addDay(-1)+"' " +
				"and (MsgSTP_iOilCons=-999999999 or MsgSTP_iETDistance=-999999999 or MsgSTP_iEWorkHours=-999999999 or MsgSTP_iMeterDistance=-999999999 ) ";
		
		
		
		String uFirstDataHandlerSql = "update Message_Stat_TimingParam set MsgSTP_iOilCons=?,MsgSTP_iETDistance=?,MsgSTP_iEWorkHours=?,MsgSTP_iMeterDistance=? " +
				",MsgSTP_iRunKmExact=?,MsgSTP_iRunKm=?,MsgSTP_iRunKmECU=? where MsgSTP_ID=?";
		
		//插入昨日数据至今日
		StringBuffer yesdayDataIstSQL = new StringBuffer();
		yesdayDataIstSQL.append("insert into Message_Stat_TimingParam");
		yesdayDataIstSQL.append("(MsgSTP_VclID," +
				"MsgSTP_iETDistance," +
				"MsgSTP_iEWorkHours," +
				"MsgSTP_iOilCons," +
				"MsgSTP_iRunKmExact,"+
				"MsgSTP_iRunKm,"+
				"MsgSTP_iRunKmECU,"+
				"MsgSTP_tETDistance," +
				"MsgSTP_tEWorkHours," +
				"MsgSTP_tOilCons," +
				"MsgSTP_tRunKmExact,"+
				"MsgSTP_tRunKm,"+
				"MsgSTP_tRunKmECU,"+
				"MsgSTP_StatTime)");
		yesdayDataIstSQL.append("select ");
		yesdayDataIstSQL.append("VehicleID,");
		yesdayDataIstSQL.append("MsgSTP_VclID,");
		yesdayDataIstSQL.append("MsgSTP_iETDistance,");
		yesdayDataIstSQL.append("MsgSTP_iEWorkHours,");
		yesdayDataIstSQL.append("MsgSTP_iOilCons,");
		yesdayDataIstSQL.append("MsgSTP_iRunKmExact,");
		yesdayDataIstSQL.append("MsgSTP_iRunKm,");
		yesdayDataIstSQL.append("MsgSTP_iRunKmECU,");
		yesdayDataIstSQL.append("MsgSTP_tETDistance,");
		yesdayDataIstSQL.append("MsgSTP_tEWorkHours,");
		yesdayDataIstSQL.append("MsgSTP_tOilCons,");
		yesdayDataIstSQL.append("MsgSTP_tRunKmExact,");
		yesdayDataIstSQL.append("MsgSTP_tRunKm,");
		yesdayDataIstSQL.append("MsgSTP_tRunKmECU,");
		yesdayDataIstSQL.append("? ");
		yesdayDataIstSQL.append("from V_VehicleInfo ");
		yesdayDataIstSQL.append("left join Message_Stat_TimingParam on VehicleID=MsgSTP_VclID and MsgSTP_StatTime='"+lastTime+"' ");
		yesdayDataIstSQL.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition is not null and Tmnl_SoftEdition<>'' ");
		
		//开始参数统计，按协议分类统计
		*//**
		 * 大一（313）协议
		 *//*
		String boAllSoftVerTerm = EquipVersionCommon.getSoftVerByAgrType("313");
		if("1".equals(map_c.get("counts").toString())){
			StringBuffer strBuff = new StringBuffer();
			strBuff.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons," +
					"MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU," +
					                                                          "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons," +
					"MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
			
			strBuff.append("select VehicleInfo.VehicleID,CAST(round(convert(float,ISNULL(tmp.ECM-ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.ECM),0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.ETDistance-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.ETDistance),0))*1.0,2) as decimal(18,2)) as iETDistance,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.tOilCons-ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.tOilCons),0))*1.0,2) as decimal(18,2)) as iOilCons,");
					
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKm-ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.MsgT_tRunKm),0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKm1-ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.MsgT_tRunKm1),0))*1.0,2) as decimal(18,2)) as iRunKm,");
			
			strBuff.append("CAST(round(convert(float,ISNULL(tmp.MsgT_tRunKmECU-ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
			strBuff.append("where MsgSTP_VclID=VehicleInfo.VehicleID and MsgSTP_StatTime=?),999999999+tmp.MsgT_tRunKmECU),0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
			
			strBuff.append("tEWorkHours=case when tmp.ECM is not null and tmp.ECM>0 then tmp.ECM else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tETDistance=case when tmp.ETDistance is not null and tmp.ETDistance>0 then tmp.ETDistance else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tOilCons=case when tmp.tOilCons is not null and tmp.tOilCons>0 then tmp.tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tRunKmExact=case when tmp.MsgT_tRunKm is not null and tmp.MsgT_tRunKm>0 then tmp.MsgT_tRunKm else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tRunKm=case when tmp.MsgT_tRunKm1 is not null and tmp.MsgT_tRunKm1>0 then tmp.MsgT_tRunKm1 else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("tRunKmECU=case when tmp.MsgT_tRunKmECU is not null and tmp.MsgT_tRunKmECU>0 then tmp.MsgT_tRunKmECU else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleInfo.VehicleID),0) end,");
			
			strBuff.append("? ");
			
			strBuff.append("from V_VehicleInfo as VehicleInfo left join ( ");
			
			strBuff.append("select *,ETDistance = CASE WHEN MsgT_tRunKm1 IS NOT NULL  THEN MsgT_tRunKm1 WHEN MsgT_tRunKm1 IS NULL  AND MsgT_tRunKm IS NOT NULL  THEN MsgT_tRunKm ELSE Isnull(MsgT_tRunKmECU,0) ");
			
			strBuff.append("END from ( SELECT VehicleID,ECM = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tEWork is not null and MsgT_tEWork >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 order by MsgT_MsgTime desc ), ");
			
			strBuff.append("MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by MsgT_MsgTime desc ) ");
			
			strBuff.append("FROM  V_VehicleInfo ) bo ");
			*//*strBuff.append("select MsgT_Vcl_ID VehicleID,MsgT_tEWork ECM,");
			strBuff.append("ETDistance=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end,");
			strBuff.append("MsgT_tOilCons tOilCons,MsgT_tRunKm,MsgT_tRunKm1,MsgT_tRunKmECU  ");
			strBuff.append("from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" " +
				"where MsgT_ID in (select MAX(MsgT_ID) from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" " +
				"where not(MsgT_tRunKm1 is null and MsgT_tRunKm is null and MsgT_tRunKmECU is null) and (MsgT_tRunKm1>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
				"and MsgT_tOilCons is not null and MsgT_tOilCons>0 and MsgT_tEWork is not null and MsgT_tEWork>0 "+
				"and exists(select * from V_VehicleInfo where VehicleID=MsgT_Vcl_ID and Tmnl_SoftEdition in ("+boAllSoftVerTerm+")) " +
				"group by MsgT_Vcl_ID) ");*//*
			strBuff.append(")as tmp on ");
			strBuff.append("tmp.VehicleID = VehicleInfo.VehicleID ");
			strBuff.append("where UsefulLife>=GETDATE() ");
			strBuff.append("and Tmnl_SoftEdition in ("+boAllSoftVerTerm+");");
			//执行录入
			baseDAO.execInsert(strBuff.toString(), new Object[]{lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,DateUtil.addDay(-1)});
			//大一，当天数据处理
			List<Map<String,Object>> firstDataHandlerList_BO = baseDAO.execQuery(firstDataHandlerSqlBo+" and Tmnl_SoftEdition in("+boAllSoftVerTerm.toString()+")", new Object[]{});
			List<String> uFirstDataHandlerSqlList_BO = new ArrayList<String>();
			List<Object[]> uFirstDataHandlerParamList_BO = new ArrayList<Object[]>();
			
			String paramKmSql_BO = "select " +
					"tmp.tKm-tmp1.tKm iKm, " +
					"tmp.MsgT_tOilCons-tmp1.MsgT_tOilCons iOil, " +
					"tmp.MsgT_tEWork-tmp1.MsgT_tEWork iTime, " +
					"tmp.MsgT_tRunKm-tmp1.MsgT_tRunKm iRunKmExact, " +
					"tmp.MsgT_tRunKm1-tmp1.MsgT_tRunKm1 iRunKm, " +
					"tmp.MsgT_tRunKmECU-tmp1.MsgT_tRunKmECU iRunKmECU " +
					"from (" +
					"SELECT tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end,* from "+
					"(SELECT MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tOilCons is not null and MsgT_tOilCons >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
					"MsgT_tEWork = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tEWork is not null and MsgT_tEWork >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
					"MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm is not null and MsgT_tRunKm >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
					"MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), "+
					"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc) "+
					"FROM V_VehicleInfo where VehicleID = ? ) bo0 ) tmp LEFT JOIN ( "+
					"SELECT tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end,* from "+
					"(SELECT MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tOilCons is not null and MsgT_tOilCons >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
					"MsgT_tEWork = (select top 1 MsgT_tEWork from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tEWork is not null and MsgT_tEWork >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
					"MsgT_tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm is not null and MsgT_tRunKm >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
					"MsgT_tRunKm1 = (select top 1 MsgT_tRunKm1 from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKm1 is not null and MsgT_tRunKm1 >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc), "+
					"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc) "+
					"FROM V_VehicleInfo where VehicleID = ? ) bo1 ) tmp1 ON 1 = 1 ";
					*//*"(select top 1 tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null " +
					"and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end, " +
					"MsgT_tOilCons, " +
					"MsgT_tEWork, " +
					"MsgT_tRunKm, " +
					"MsgT_tRunKm1, " +
					"MsgT_tRunKmECU " +
					"from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" " +
					"where MsgT_Vcl_ID=? " +
					"and not(MsgT_tRunKm1 is null and MsgT_tRunKm is null and MsgT_tRunKmECU is null) " +
					"and (MsgT_tRunKm1>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
					"and MsgT_tOilCons is not null and MsgT_tOilCons>0 " +
					"and MsgT_tEWork is not null and MsgT_tEWork>0 order by MsgT_ID desc)tmp " +
					"left join " +
					"(select top 1 tKm=case when MsgT_tRunKm1 is not null then MsgT_tRunKm1 when MsgT_tRunKm1 is null " +
					"and MsgT_tRunKm is not null then MsgT_tRunKm else ISNULL(MsgT_tRunKmECU,0) end, " +
					"MsgT_tOilCons, " +
					"MsgT_tEWork, " +
					"MsgT_tRunKm, " +
					"MsgT_tRunKm1, " +
					"MsgT_tRunKmECU " +
					"from CTY_Egn_A.dbo.Msg_Timing_"+tableDate+" " +
					"where MsgT_Vcl_ID=? " +
					"and not(MsgT_tRunKm1 is null and MsgT_tRunKm is null and MsgT_tRunKmECU is null) " +
					"and (MsgT_tRunKm1>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
					"and MsgT_tOilCons is not null and MsgT_tOilCons>0 " +
					"and MsgT_tEWork is not null and MsgT_tEWork>0 order by MsgT_ID asc)tmp1 " +
					"on 1=1";*//*
			
			for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList_BO){
				uFirstDataHandlerSqlList_BO.add(uFirstDataHandlerSql);
				Map<String,Object> paramMap = baseDAO.execQueryOne(paramKmSql_BO, 
						new Object[]{
								MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
								MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID")
							});
				
				uFirstDataHandlerParamList_BO.add(new Object[]{this.getFloat(paramMap, "iOil"),
						this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),"0.0",
						this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
						MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
			}
			if(uFirstDataHandlerSqlList_BO.size()>0)
				tranDAO.batch(uFirstDataHandlerSqlList_BO, uFirstDataHandlerParamList_BO);
		}else{
			String yesdayDataIstSQL313 = yesdayDataIstSQL.toString()+" and Tmnl_SoftEdition in ("+boAllSoftVerTerm+");";
			baseDAO.execInsert(yesdayDataIstSQL313, new Object[]{DateUtil.addDay(-1)});
		}
		
		*//**
		 * 小一403协议
		 *//*
		String soJSoftVerTerm = EquipVersionCommon.getSoftVerByAgrType("403");
		if("1".equals(MapGetter.getString(msgCan, "counts"))){
			String selVclSQL403 = "select VehicleID from V_VehicleInfo where UsefulLife>=GETDATE() and Tmnl_SoftEdition in ("+soJSoftVerTerm+");";
			List<Map<String,Object>> vclList403 = baseDAO.execQuery(selVclSQL403, new Object[]{});
			
			StringBuffer strBuff403 = new StringBuffer();
			
			String vclId403;
			for(Map<String,Object> vclMap403:vclList403){
				strBuff403.setLength(0);
				
				vclId403 = MapGetter.getString(vclMap403, "VehicleID");
				
				strBuff403.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons," +
				"MsgSTP_iMeterDistance,MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU,"+
//				"MsgSTP_tMeterDistance,MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,"+		
						                                                             "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons" +
						                                                             ",MsgSTP_tMeterDistance,MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
				
				strBuff403.append("select VehicleID,CAST(round(convert(float,ISNULL(tmp.ECM-ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.ECM),0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.ETDistance-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.ETDistance),0))*1.0,2) as decimal(18,2)) as iETDistance,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tOilCons-ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.tOilCons),0))*1.0,2) as decimal(18,2)) as iOilCons,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm4-ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.tKm4),0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm1-ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.tKm1),0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm2-ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.tKm2),0))*1.0,2) as decimal(18,2)) as iRunKm,");
				
				strBuff403.append("CAST(round(convert(float,ISNULL(tmp.tKm3-ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
				strBuff403.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmp.tKm3),0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
				
				strBuff403.append("tEWorkHours=case when tmp.ECM is not null and tmp.ECM>0 then tmp.ECM else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tETDistance=case when tmp.ETDistance is not null and tmp.ETDistance>0 then tmp.ETDistance else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tOilCons=case when tmp.tOilCons is not null and tmp.tOilCons>0 then tmp.tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tMeterDistance=case when tmp.tKm4 is not null and tmp.tKm4>0 then tmp.tKm4 else ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKmExact=case when tmp.tKm1 is not null and tmp.tKm1>0 then tmp.tKm1 else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKm=case when tmp.tKm2 is not null and tmp.tKm2>0 then tmp.tKm2 else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("tRunKmECU=case when tmp.tKm3 is not null and tmp.tKm3>0 then tmp.tKm3 else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff403.append("? ");
				
				strBuff403.append("from ( select *,ETDistance=case when can.tKm2 is not null then can.tKm2 when can.tKm1 is not null then can.tKm1 else isnull(can.tKm3,0) end ");
				
				strBuff403.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
				
				strBuff403.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" mc INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
				
				strBuff403.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
				
				strBuff403.append("FROM  V_VehicleInfo AS vehicleinfo where VehicleID = "+vclId403+" )can ) tmp ");
				
				*//*strBuff403.append("from V_VehicleInfo as VehicleInfo left join (");
				
				strBuff403.append("select top 1 tTime.MsgC_Vcl_ID, tTime.tTime ECM, tOil.tOil tOilCons,tKm1,tKm2,tKm3,tKm4," +
						"ETDistance=case when tKm2.tKm2 is not null then tKm2.tKm2 when tKm1.tKm1 is not null then tKm1.tKm1 else isnull(tKm3.tKm3,0) end from ");
				strBuff403.append("(");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tTime,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=20 and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tTime ");
				strBuff403.append("left join( ");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tOil,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=22  and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tOil on tTime.MsgC_ID=tOil.MsgC_ID ");
				strBuff403.append("left join(");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tKm1,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=27  and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tKm1 on tOil.MsgC_ID=tKm1.MsgC_ID ");
				strBuff403.append("left join(");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tKm2,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=28  and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tKm2 on tKm1.MsgC_ID=tKm2.MsgC_ID ");
				strBuff403.append("left join(");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tKm3,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=29  and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tKm3 on tKm2.MsgC_ID=tKm3.MsgC_ID ");
				strBuff403.append("left join(");
				strBuff403.append("select MsgC_ID,MsgCCo_ParmValue tKm4,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
				strBuff403.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=53  and MsgC_Vcl_ID="+vclId403+" ");
				strBuff403.append(")tKm4 on tKm3.MsgC_ID=tKm4.MsgC_ID ");	
				strBuff403.append("where tTime.tTime is not null and tTime.tTime>0 ");
				strBuff403.append("and tOil.tOil is not null and tOil.tOil>0 ");
				strBuff403.append("and tKm4.tKm4 is not null and tKm4.tKm4>0 ");
				strBuff403.append("and not(tKm1.tKm1 is null and tKm2.tKm2 is null and tKm3.tKm3 is null) ");
				strBuff403.append("and not(tKm1.tKm1<0 and tKm2.tKm2<0 and tKm3.tKm3<0)");
				strBuff403.append("order by tTime.MsgC_ID desc) tmp on tmp.MsgC_Vcl_ID=VehicleInfo.VehicleID where VehicleInfo.VehicleID="+vclId403+" ");*//*
				baseDAO.execInsert(strBuff403.toString(), new Object[]{lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,DateUtil.addDay(-1)});
			}
			
			//小一（403），当天数据处理
			List<Map<String,Object>> firstDataHandlerList_SO = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+soJSoftVerTerm+")", new Object[]{});
			List<String> uFirstDataHandlerSqlList_SO = new ArrayList<String>();
			List<Object[]> uFirstDataHandlerParamList_SO = new ArrayList<Object[]>();
			
			StringBuffer paramSql_SO = new StringBuffer();
			paramSql_SO.append("select tmp.ECM-tmp1.ECM iTime,tmp.tETDistance-tmp1.tETDistance iKm,tmp.tOilCons-tmp1.tOilCons iOil, " +
			                   "tmp.tKm4-tmp1.tKm4 iMeterDistance,tmp.tKm1-tmp1.tKm1 iRunKmExact,tmp.tKm2-tmp1.tKm2 iRunKm,tmp.tKm3-tmp1.tKm3 iRunKmECU from (");
			paramSql_SO.append("select *,tETDistance=case when can.tKm2 is not null then can.tKm2 when can.tKm1 is not null then can.tKm1 else isnull(can.tKm3,0) end ");
			paramSql_SO.append("from ( SELECT VehicleID,ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
			paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
			paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
			paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
			paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+"  INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc), ");
			paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime desc) ");
			paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can ) tmp ");
			paramSql_SO.append("LEFT JOIN (select *,tETDistance=case when can1.tKm2 is not null then can1.tKm2 when can1.tKm1 is not null then can1.tKm1 else isnull(can1.tKm3,0) end ");
			paramSql_SO.append("from ( SELECT VehicleID, ECM = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 20  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
			paramSql_SO.append("tOilCons = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 22  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
			paramSql_SO.append("tKm1= (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 27  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
			paramSql_SO.append("tKm2 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 28  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
			paramSql_SO.append("tKm3 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 29  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc), ");
			paramSql_SO.append("tKm4 = (SELECT  top 1 MsgCCo_ParmValue FROM  CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" ON MsgC_ID = MsgCCo_MsgC_ID ");
			paramSql_SO.append("WHERE  MsgCCo_SysCP_ID = 53  and MsgCCo_ParmValue is not null and MsgCCo_ParmValue>0  AND MsgC_Vcl_ID = VehicleID order by MsgC_MsgTime asc)  ");
			paramSql_SO.append("FROM  v_vehicleinfo AS vehicleinfo where VehicleID = ? )can1 ) tmp1 ON 1 = 1 ");
			*//*paramSql_SO.append("select top 1 tTime.MsgC_Vcl_ID, tTime.tTime ECM, tOil.tOil tOilCons,");
			paramSql_SO.append("tETDistance=case when tKm2.tKm2 is not null then tKm2.tKm2 when tKm1.tKm1 is not null then tKm1.tKm1 else isnull(tKm3.tKm3,0) end,tKm4,tKm1,tKm2,tKm3 from ");
			paramSql_SO.append("(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tTime,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=20 and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tTime ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tOil,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=22  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tOil on tTime.MsgC_ID=tOil.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm1,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=27  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm1 on tOil.MsgC_ID=tKm1.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm2,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=28  and MsgC_Vcl_ID=? " );
			paramSql_SO.append(")tKm2 on tKm1.MsgC_ID=tKm2.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm3,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=29  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm3 on tKm2.MsgC_ID=tKm3.MsgC_ID ");		
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm4,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=53  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm4 on tKm3.MsgC_ID=tKm4.MsgC_ID ");			
			paramSql_SO.append("where tTime.tTime is not null and tTime.tTime>0 ");
			paramSql_SO.append("and tOil.tOil is not null and tOil.tOil>0 ");
			paramSql_SO.append("and tKm4.tKm4 is not null and tKm4.tKm4>0 ");
			paramSql_SO.append("and not(tKm1.tKm1 is null and tKm2.tKm2 is null and tKm3.tKm3 is null) ");
			paramSql_SO.append("and not(tKm1.tKm1<0 and tKm2.tKm2<0 and tKm3.tKm3<0) order by tTime.MsgC_ID desc ");
			paramSql_SO.append(") tmp ");
			paramSql_SO.append("left join ");
			paramSql_SO.append("(");
			paramSql_SO.append("select top 1 tTime.MsgC_Vcl_ID, tTime.tTime ECM, tOil.tOil tOilCons,");
			paramSql_SO.append("tETDistance=case when tKm2.tKm2 is not null then tKm2.tKm2 when tKm1.tKm1 is not null then tKm1.tKm1 else isnull(tKm3.tKm3,0) end ,tKm4,tKm1,tKm2,tKm3 from ");
			paramSql_SO.append("(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tTime,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=20 and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tTime ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tOil,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=22  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tOil on tTime.MsgC_ID=tOil.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm1,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=27  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm1 on tOil.MsgC_ID=tKm1.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm2,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=28  and MsgC_Vcl_ID=? " );
			paramSql_SO.append(")tKm2 on tKm1.MsgC_ID=tKm2.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm3,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=29  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm3 on tKm2.MsgC_ID=tKm3.MsgC_ID ");
			paramSql_SO.append("left join(");
			paramSql_SO.append("select MsgCCo_ID,MsgC_ID,MsgCCo_ParmValue tKm4,MsgC_Vcl_ID from CTY_Egn_B.dbo.Msg_CAN_"+tableDate+" ");
			paramSql_SO.append("inner join CTY_Egn_B.dbo.Msg_CAN_Content_"+tableDate+" on MsgC_ID=MsgCCo_MsgC_ID where MsgCCo_SysCP_ID=53  and MsgC_Vcl_ID=? ");
			paramSql_SO.append(")tKm4 on tKm3.MsgC_ID=tKm4.MsgC_ID ");
			paramSql_SO.append("where tTime.tTime is not null and tTime.tTime>0 ");
			paramSql_SO.append("and tOil.tOil is not null and tOil.tOil>0 ");
			paramSql_SO.append("and tKm4.tKm4 is not null and tKm4.tKm4>0 ");
			paramSql_SO.append("and not(tKm1.tKm1 is null and tKm2.tKm2 is null and tKm3.tKm3 is null) ");
			paramSql_SO.append("and not(tKm1.tKm1<0 and tKm2.tKm2<0 and tKm3.tKm3<0) order by tTime.MsgC_ID asc ");
			paramSql_SO.append(")tmp1 on 1=1 ");*//*
			for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList_SO){
				uFirstDataHandlerSqlList_SO.add(uFirstDataHandlerSql);
				Map<String,Object> paramMap = baseDAO.execQueryOne(paramSql_SO.toString(), 
						new Object[]{
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									/*MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID"),*//*
									MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID")
								});
				
				uFirstDataHandlerParamList_SO.add(new Object[]{this.getFloat(paramMap, "iOil"),
						this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),this.getFloat(paramMap, "iMeterDistance"),
						this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
						MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
			}
			if(uFirstDataHandlerSqlList_SO.size()>0)
				tranDAO.batch(uFirstDataHandlerSqlList_SO, uFirstDataHandlerParamList_SO);
		}else{
			String yesdayDataIstSQL403 = yesdayDataIstSQL.toString()+"and Tmnl_SoftEdition in ("+soJSoftVerTerm+");";
			baseDAO.execInsert(yesdayDataIstSQL403, new Object[]{DateUtil.addDay(-1)});
		}
		
		*//**
		 * 小一412协议-设备统计
		 *//*
		try {
			//412协议包含的软件版本号
			String termSoftVer412 = EquipVersionCommon.getSoftVerByAgrType("412");
			StringBuffer strBuff412 = new StringBuffer();
			if(MapGetter.getString(msgT, "counts").equals("1")){
				strBuff412.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons,");
				if(MapGetter.getString(msgU, "counts").equals("1")){
					strBuff412.append("MsgSTP_iMeterDistance,");
				}
				strBuff412.append("MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,");
				if(MapGetter.getString(msgU, "counts").equals("1")){
					strBuff412.append("MsgSTP_tMeterDistance,");
				}
				strBuff412.append("MsgSTP_StatTime)");
				
				strBuff412.append("select VehicleID,CAST(round(convert(float,ISNULL(MsgT_tWorkTime_UDS-ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
				strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tWorkTime_UDS),0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				strBuff412.append("CAST(round(convert(float,ISNULL(MsgT_tRunKm_UDS-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
				strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKm_UDS),0))*1.0,2) as decimal(18,2)) as iETDistance,");
				
				strBuff412.append("CAST(round(convert(float,ISNULL(MsgT_tOilCons_UDS-ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
				strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tOilCons_UDS),0))*1.0,2) as decimal(18,2)) as iOilCons,");
				
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				if(MapGetter.getString(msgU, "counts").equals("1")){
					strBuff412.append("CAST(round(convert(float,ISNULL(MsgU_tMeterDis-ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
					strBuff412.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgU_tMeterDis),0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
				}
				*//**********仪表里程 ****LXF***20130722****END*****//*
				
				strBuff412.append("tEWorkHours=case when MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 then MsgT_tWorkTime_UDS else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff412.append("tETDistance=case when MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS>0 then MsgT_tRunKm_UDS else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff412.append("tOilCons=case when MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS>0 then MsgT_tOilCons_UDS else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				if(MapGetter.getString(msgU, "counts").equals("1")){
					strBuff412.append("tMeterDistance=case when MsgU_tMeterDis is not null and MsgU_tMeterDis>0 then MsgU_tMeterDis else ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				}
				*//**********仪表里程 ****LXF***20130722****END*****//*
				
				strBuff412.append("? ");
				strBuff412.append("from (SELECT VehicleID,MsgT_tRunKm_UDS  = (select top 1 MsgT_tRunKm_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), ");
				strBuff412.append("MsgT_tOilCons_UDS = (select top 1 MsgT_tOilCons_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc), ");
				strBuff412.append("MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS > 0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc)  ");
				strBuff412.append("FROM  V_VehicleInfo WHERE  UsefulLife >= Getdate() AND Tmnl_SoftEdition <> '' AND Tmnl_SoftEdition IS NOT NULL  AND Tmnl_SoftEdition IN ("+termSoftVer412.toString()+")) tmpTab  ");
				/*strBuff412.append("from V_VehicleInfo left join (");
				//里程、油耗、工作小时
				strBuff412.append("select MsgT_Vcl_ID,MsgT_tRunKm_UDS,MsgT_tOilCons_UDS,MsgT_tWorkTime_UDS from V_VehicleInfo ");
				strBuff412.append("left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID=MsgT_Vcl_ID ");
				strBuff412.append("and MsgT_ID in (");
				strBuff412.append("select MAX(MsgT_ID) from ");
				strBuff412.append("CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" ");
				strBuff412.append("where MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS>0 and MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS>0 and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 group by MsgT_Vcl_ID)");
				strBuff412.append(")tmpTab on VehicleID=tmpTab.MsgT_Vcl_ID ");
				*//*
				//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				//仪表里程	PP参数：发动机行驶里程   SysU_ID：96  SysU_UDSID：3027
				if(MapGetter.getString(msgU, "counts").equals("1")){
					strBuff412.append("left join(");
					strBuff412.append("select MsgU_Vcl_ID,CONVERT(float,MsgUC_UDSValue) as MsgU_tMeterDis,MsgU_MsgTime from V_VehicleInfo ");
					strBuff412.append("left join CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" on MsgU_Vcl_ID=VehicleID ");
					strBuff412.append("inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+" on MsgUC_MsgU_ID=MsgU_ID ");
					strBuff412.append("inner join ( ");
					strBuff412.append("select MAX(MsgUC_ID)MsgUCID from CTY_Egn_B.dbo.Msg_UDS_"+tableDate+" "); 
					strBuff412.append("inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+" on MsgUC_MsgU_ID=MsgU_ID ");
					strBuff412.append("where MsgUC_UDSID='3027' and MsgUC_UDSValue is not null ");
					strBuff412.append("group by MsgU_Vcl_ID "); 
					strBuff412.append(") tmp on tmp.MsgUCID = MsgUC_ID");
					strBuff412.append(")tmpMeter on VehicleID=tmpMeter.MsgU_Vcl_ID ");
				}
				//**********仪表里程 ****LXF***20130722****END*****//*
				
//				strBuff412.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition<>'' and Tmnl_SoftEdition is not null and Tmnl_SoftEdition in("+termSoftVer412.toString()+");");
				baseDAO.execInsert(strBuff412.toString(), new Object[]{lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,DateUtil.addDay(-1)});
				
				//当天数据处理
				List<Map<String,Object>> firstDataHandlerList = baseDAO.execQuery(firstDataHandlerSql412+" and Tmnl_SoftEdition in("+termSoftVer412.toString()+")", new Object[]{});
				List<String> uFirstDataHandlerSqlList = new ArrayList<String>();
				List<Object[]> uFirstDataHandlerParamList = new ArrayList<Object[]>();
				
				String paramKmSql = "select tmp.MsgT_tRunKm_UDS-tmp1.MsgT_tRunKm_UDS iKm," +
						"tmp.MsgT_tOilCons_UDS-tmp1.MsgT_tOilCons_UDS iOil," +
						"tmp.MsgT_tWorkTime_UDS-tmp1.MsgT_tWorkTime_UDS iTime " +
						"from " +
						"(SELECT MsgT_tRunKm_UDS = (select top 1 MsgT_tRunKm_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc)," +
						"MsgT_tOilCons_UDS =(select top 1 MsgT_tOilCons_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc)," +
						"MsgT_tWorkTime_UDS =(select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime desc) " +
						"FROM  V_VehicleInfo where VehicleID = ?) tmp LEFT JOIN ( " +
						"SELECT   MsgT_tRunKm_UDS = (select top 1 MsgT_tRunKm_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc)," +
						"MsgT_tOilCons_UDS =(select top 1 MsgT_tOilCons_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc)," +
						"MsgT_tWorkTime_UDS =(select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 and MsgT_Vcl_ID = VehicleID order by MsgT_MsgTime asc) " +
						"FROM  V_VehicleInfo where VehicleID = ?) tmp1 ON 1 = 1;";
						/*"(select top 1 MsgT_tRunKm_UDS,MsgT_tOilCons_UDS,MsgT_tWorkTime_UDS " +
						"from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" " +
						"where MsgT_Vcl_ID=? " +
						"and MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS>0 " +
						"and MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS>0 " +
						"and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 order by MsgT_ID desc)tmp " +
						"left join " +
						"(select top 1 MsgT_tRunKm_UDS,MsgT_tOilCons_UDS,MsgT_tWorkTime_UDS " +
						"from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" " +
						"where MsgT_Vcl_ID=? " +
						"and MsgT_tRunKm_UDS is not null and MsgT_tRunKm_UDS>0 " +
						"and MsgT_tOilCons_UDS is not null and MsgT_tOilCons_UDS>0 " +
						"and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 order by MsgT_ID asc)tmp1 " +
						"on 1=1";*//*
				//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				String updateIMeterDistanceSql = "select CONVERT(float,tmpE.MsgUC_UDSValue)-CONVERT(float,tmpB.MsgUC_UDSValue) iMeterDistance from ( "
					+"select top 1 MsgU_Vcl_ID,MsgUC_UDSValue,MsgU_MsgTime,MsgUC_MsgU_ID,MsgUC_ID from V_VehicleInfo "
					+"left join CTY_Egn_B.dbo.Msg_UDS_"+tableDate+"  on MsgU_Vcl_ID=VehicleID "
					+"inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+"  on MsgUC_MsgU_ID=MsgU_ID "
					+"where MsgUC_UDSID='3027' and MsgUC_UDSValue is not null  and MsgU_Vcl_ID=? order by MsgU_ID asc,MsgUC_ID asc)tmpB "
					+"left join ( "
					+"select top 1 MsgU_Vcl_ID,MsgUC_UDSValue,MsgU_MsgTime,MsgUC_MsgU_ID,MsgUC_ID from V_VehicleInfo "
					+"left join CTY_Egn_B.dbo.Msg_UDS_"+tableDate+"  on MsgU_Vcl_ID=VehicleID "
					+"inner join CTY_Egn_B.dbo.Msg_UDS_Content_"+tableDate+"  on MsgUC_MsgU_ID=MsgU_ID "
					+"where MsgUC_UDSID='3027' and MsgUC_UDSValue is not null  and MsgU_Vcl_ID=? order by MsgU_ID desc,MsgUC_ID desc)tmpE on 1=1";
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList){
					uFirstDataHandlerSqlList.add(uFirstDataHandlerSql);
					String VclID = MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID");
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramKmSql, new Object[]{VclID,VclID});
					Map<String,Object> paramMapMeter = baseDAO.execQueryOne(updateIMeterDistanceSql, new Object[]{VclID,VclID});
					uFirstDataHandlerParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),this.getFloat(paramMapMeter, "iMeterDistance"),"0.0","0.0","0.0",
							MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
				}
				if(uFirstDataHandlerSqlList.size()>0)
					tranDAO.batch(uFirstDataHandlerSqlList, uFirstDataHandlerParamList);
			}else{
				String yesdayDataIstSQL412 = yesdayDataIstSQL.toString()+"and Tmnl_SoftEdition in ("+termSoftVer412.toString()+");";
				baseDAO.execInsert(yesdayDataIstSQL412, new Object[]{DateUtil.addDay(-1)});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		*//**
		 * 小一414协议-设备统计
		 *//*
		try {
			//414协议包含的软件版本号
			String termSoftVer414 = EquipVersionCommon.spltSoftVer(EquipVersionCommon.getSoftVerByAgrType("414"),EquipVersionCommon.getSoftVerByAgrType("418"),EquipVersionCommon.getSoftVerByAgrType("420"),EquipVersionCommon.getSoftVerByAgrType("423"),EquipVersionCommon.getSoftVerByAgrType("424"));
			StringBuffer strBuff414 = new StringBuffer();
			if(MapGetter.getString(msgT, "counts").equals("1")){
				strBuff414.append("insert into Message_Stat_TimingParam (MsgSTP_VclID,MsgSTP_iEWorkHours,MsgSTP_iETDistance,MsgSTP_iOilCons,MsgSTP_iMeterDistance," +
			    "MsgSTP_iRunKmExact,MsgSTP_iRunKm,MsgSTP_iRunKmECU,"+
						                                                             "MsgSTP_tEWorkHours,MsgSTP_tETDistance,MsgSTP_tOilCons,MsgSTP_tMeterDistance," +
				"MsgSTP_tRunKmExact,MsgSTP_tRunKm,MsgSTP_tRunKmECU,MsgSTP_StatTime)");
				
				strBuff414.append("select VehicleID,CAST(round(convert(float,ISNULL(MsgT_tWorkTime_UDS-ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tWorkTime_UDS),0))*1.0,2) as decimal(18,2)) as iEWorkHours,");
				
				strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKm-ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKm),0))*1.0,2) as decimal(18,2)) as iETDistance,");
				
				strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tOilCons-ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tOilCons),0))*1.0,2) as decimal(18,2)) as iOilCons,");
				
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
//				if(MapGetter.getString(msgP, "counts").equals("1")){
					strBuff414.append("CAST(round(convert(float,ISNULL(MsgP_tMeterDis-ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam ");
					strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgP_tMeterDis),0))*1.0,2) as decimal(18,2)) as iMeterDistance,");
//				}
				*//**********仪表里程 ****LXF***20130722****END*****//*
				
				strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmExact-ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKmExact),0))*1.0,2) as decimal(18,2)) as iRunKmExact,");
				
				strBuff414.append("CAST(round(convert(float,ISNULL(tmpTab.tRunKm-ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+tmpTab.tRunKm),0))*1.0,2) as decimal(18,2)) as iRunKm,");
				
				strBuff414.append("CAST(round(convert(float,ISNULL(MsgT_tRunKmECU-ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam ");
				strBuff414.append("where MsgSTP_VclID=VehicleID and MsgSTP_StatTime=?),999999999+MsgT_tRunKmECU),0))*1.0,2) as decimal(18,2)) as iRunKmECU,");
				
				strBuff414.append("tEWorkHours=case when MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 then MsgT_tWorkTime_UDS else ISNULL((select MsgSTP_tEWorkHours from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff414.append("tETDistance=case when MsgT_tRunKm is not null and MsgT_tRunKm>0 then MsgT_tRunKm else ISNULL((select MsgSTP_tETDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff414.append("tOilCons=case when MsgT_tOilCons is not null and MsgT_tOilCons>0 then MsgT_tOilCons else ISNULL((select MsgSTP_tOilCons from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
//				if(MapGetter.getString(msgP, "counts").equals("1")){
					strBuff414.append("tMeterDistance=case when MsgP_tMeterDis is not null and MsgP_tMeterDis>0 then MsgP_tMeterDis else ISNULL((select MsgSTP_tMeterDistance from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
//				}
				*//**********仪表里程 ****LXF***20130722****END*****//*
				strBuff414.append("tRunKmExact=case when MsgT_tRunKmExact is not null and MsgT_tRunKmExact>0 then MsgT_tRunKmExact else ISNULL((select MsgSTP_tRunKmExact from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff414.append("tRunKm=case when tmpTab.tRunKm is not null and tmpTab.tRunKm>0 then tmpTab.tRunKm else ISNULL((select MsgSTP_tRunKm from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				strBuff414.append("tRunKmECU=case when MsgT_tRunKmECU is not null and MsgT_tRunKmECU>0 then MsgT_tRunKmECU else ISNULL((select MsgSTP_tRunKmECU from Message_Stat_TimingParam where MsgSTP_StatTime=? and MsgSTP_VclID=VehicleID),0) end,");
				
				strBuff414.append("? ");
				strBuff414.append("from V_VehicleInfo left join (");
				//里程、油耗、工作小时
				strBuff414.append("select VehicleID as MsgT_Vcl_ID,");
				strBuff414.append("MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm when MsgT_tRunKm is null " +
				        /*jiyongtian 20140410 去掉*//*
						/*"and MsgT_tRunKmExact is not null then MsgT_tRunKmExact else ISNULL(MsgT_tRunKmECU,0) end,MsgT_tOilCons,MsgT_tWorkTime_UDS," +
						"MsgT_tRunKmECU,MsgT_tRunKmExact,MsgT_tRunKm as tRunKm,MsgP_tMeterDis = case when MsgT_tRunKmExact_PGN is not null then MsgT_tRunKmExact_PGN ");*//*
						"and MsgT_tRunKmExact is not null then MsgT_tRunKmExact else ISNULL(MsgT_tRunKmECU,0) end," +
						"MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tOilCons is not null and MsgT_tOilCons >0 order by MsgT_MsgTime desc)," +
						"MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0 order by MsgT_MsgTime desc)," +
						"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0 order by  MsgT_MsgTime desc)," +
						"MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0 order by  MsgT_MsgTime desc)," +
						"tRunKm = (select top 1 MsgT_tRunKm from CTY_EGN_b.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and MsgT_tRunKm is not null and MsgT_tRunKm >0 order by  MsgT_MsgTime desc)," +
						"MsgP_tMeterDis = case when MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 then MsgT_tRunKmExact_PGN ");
				
				if(MapGetter.getString(msgP, "counts").equals("1")){
					strBuff414.append(" else ISNULL(tmpMeter.MsgP_tMeterDis,0) end ");
				}else{
					strBuff414.append(" else 0 end ");
				}
				strBuff414.append("from V_VehicleInfo ");				
				strBuff414.append("left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID=MsgT_Vcl_ID ");
				strBuff414.append("and MsgT_ID in (");
				strBuff414.append("select MAX(MsgT_ID) from ");
				strBuff414.append("CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" ");
				strBuff414.append("where MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN >0 group by MsgT_Vcl_ID ) ");
				/*jiyongtian 20140410 去掉*//*
				/*strBuff414.append("where (MsgT_tRunKmExact is not null or MsgT_tRunKm is not null or MsgT_tRunKmECU is not null) " +
						"and (MsgT_tRunKmExact>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
						"and MsgT_tOilCons is not null and MsgT_tOilCons>0 " +
						"and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 group by MsgT_Vcl_ID)");*//*
				
				*//**********仪表里程 ****LXF***20130722****BEGIN*****//*
				//仪表里程	PGN参数：高分辨率总车辆行驶里程(EE)   SysPIP_ID：405  SysPI_ID：65
				if(MapGetter.getString(msgP, "counts").equals("1")){
					strBuff414.append("left join(");
					strBuff414.append("select MsgP_Vcl_ID,CONVERT(float,MsgPC_PGNValue) as MsgP_tMeterDis,MsgP_MsgTime from V_VehicleInfo ");
					strBuff414.append("left join CTY_Egn_B.dbo.Msg_PGN_"+tableDate+"  on MsgP_Vcl_ID=VehicleID  ");
					strBuff414.append("inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+"  on MsgP_ID=MsgPC_MsgP_ID ");
					strBuff414.append("inner join ( ");
					strBuff414.append("select MAX(MsgPC_ID)MsgPCID from CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" ");
					strBuff414.append("inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+"  on MsgP_ID=MsgPC_MsgP_ID ");
					strBuff414.append("where MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null ");
					strBuff414.append("group by MsgP_Vcl_ID ");
					strBuff414.append(") tmp on tmp.MsgPCID = MsgPC_ID");
					strBuff414.append(")tmpMeter on VehicleID=tmpMeter.MsgP_Vcl_ID ");
				}
				*//**********仪表里程 ****LXF***20130722****END*****//*
				strBuff414.append(")tmpTab on VehicleID=tmpTab.MsgT_Vcl_ID ");
				strBuff414.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVer414.toString()+");");
				baseDAO.execInsert(strBuff414.toString(), new Object[]{lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,lastTime,DateUtil.addDay(-1)});
				
				//当天数据处理
				List<Map<String,Object>> firstDataHandlerList = baseDAO.execQuery(firstDataHandlerSql+" and Tmnl_SoftEdition in("+termSoftVer414.toString()+")", new Object[]{});
				List<String> uFirstDataHandlerSqlList = new ArrayList<String>();
				List<Object[]> uFirstDataHandlerParamList = new ArrayList<Object[]>();
				
				String paramKmSql = "select tmp.MsgT_tRunKm-tmp1.MsgT_tRunKm iKm, " +
						"tmp.MsgT_tOilCons-tmp1.MsgT_tOilCons iOil, " +
						"tmp.MsgT_tWorkTime_UDS-tmp1.MsgT_tWorkTime_UDS iTime," +						
						"tmp.MsgT_tRunKmExact-tmp1.MsgT_tRunKmExact iRunKmExact, " +
						"tmp.tRunKm-tmp1.tRunKm iRunKm, " +
						"tmp.MsgT_tRunKmECU-tmp1.MsgT_tRunKmECU iRunKmECU, " +
						"tmp.MsgT_tRunKmExact_PGN-tmp1.MsgT_tRunKmExact_PGN iRunKmExact_PGN  " +
						"from (" +
						"select MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm " +
						"when MsgT_tRunKm is null and MsgT_tRunKmExact is not null then MsgT_tRunKmExact " +
						"else ISNULL(MsgT_tRunKmECU,0) end," +
						"MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tOilCons is not null and MsgT_tOilCons >0  order by MsgT_MsgTime desc)," +
						"MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0  order by MsgT_MsgTime desc), " +
						"MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0  order by MsgT_MsgTime desc)," +
						"tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKm is not null and MsgT_tRunKm >0  order by MsgT_MsgTime desc)," +
						"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU  from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0  order by MsgT_MsgTime desc)," +
						"MsgT_tRunKmExact_PGN = case when MsgT_tRunKmExact_PGN IS not null and MsgT_tRunKmExact_PGN >0 then MsgT_tRunKmExact_PGN ";
				if(MapGetter.getString(msgP, "counts").equals("1")){
					paramKmSql += " else ISNULL(MsgP_tMeterDis,0) end ";
				}else{
					paramKmSql += " else 0 end ";
				}
				paramKmSql +=" from V_VehicleInfo left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID= MsgT_Vcl_ID and MsgT_ID in (select MAX(MsgT_ID) from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN>0 group by MsgT_Vcl_ID) ";
				if(MapGetter.getString(msgP, "counts").equals("1")){
					paramKmSql += "left join ( SELECT MsgP_Vcl_ID, Convert(FLOAT,MsgPC_PGNValue) AS MsgP_tMeterDis FROM  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" ON MsgP_ID = MsgPC_MsgP_ID "+
							"and MsgPC_ID in ( SELECT Max(MsgPC_ID) MsgPC_ID  From CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgPC_MsgP_ID = MsgP_ID WHERE MsgPC_SysPIP_ID = 405 AND MsgPC_SysPI_ID = 65 AND MsgPC_PGNValue IS NOT NULL  GROUP BY MsgP_Vcl_ID))temp_meter on temp_meter.MsgP_Vcl_ID = VehicleID ";
				}
				paramKmSql += "where VehicleID = ?)tmp " +
						*//*"and (MsgT_tRunKmExact is not null or MsgT_tRunKm is not null or MsgT_tRunKmECU is not null) " +
						"and (MsgT_tRunKmExact>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
						"and MsgT_tOilCons is not null and MsgT_tOilCons>0 " +
						"and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 order by MsgT_ID desc)tmp " +*//*
						"left join " +
						"(select top 1 MsgT_tRunKm=case when MsgT_tRunKm is not null then MsgT_tRunKm " +
						"when MsgT_tRunKm is null and MsgT_tRunKmExact is not null then MsgT_tRunKmExact " +
						"else ISNULL(MsgT_tRunKmECU,0) end," +
						"MsgT_tOilCons = (select top 1 MsgT_tOilCons from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tOilCons is not null and MsgT_tOilCons >0  order by MsgT_MsgTime ASC)," +
						"MsgT_tWorkTime_UDS = (select top 1 MsgT_tWorkTime_UDS from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS >0  order by MsgT_MsgTime ASC)," +
						"MsgT_tRunKmExact = (select top 1 MsgT_tRunKmExact from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmExact is not null and MsgT_tRunKmExact >0  order by MsgT_MsgTime asc)," +
						"tRunKm = (select top 1 MsgT_tRunKm from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKm is not null and MsgT_tRunKm >0  order by MsgT_MsgTime asc)," +
						"MsgT_tRunKmECU = (select top 1 MsgT_tRunKmECU  from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_Vcl_ID = VehicleID and  MsgT_tRunKmECU is not null and MsgT_tRunKmECU >0  order by MsgT_MsgTime asc)," +
						"MsgT_tRunKmExact_PGN = case when MsgT_tRunKmExact_PGN IS not null and MsgT_tRunKmExact_PGN >0 then MsgT_tRunKmExact_PGN  ";
				if(MapGetter.getString(msgP, "counts").equals("1")){
					paramKmSql += " else ISNULL(MsgP_tMeterDis,0) end ";
				}else{
					paramKmSql += " else 0 end ";
				}
				paramKmSql += " from V_VehicleInfo left join CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" on VehicleID=MsgT_Vcl_ID and MsgT_ID in (select MIN(MsgT_ID) from CTY_Egn_B.dbo.Msg_Timing_"+tableDate+" where MsgT_tRunKmExact_PGN is not null and MsgT_tRunKmExact_PGN>0 group by MsgT_Vcl_ID) ";
				if(MapGetter.getString(msgP, "counts").equals("1")){
					paramKmSql += " left join ( SELECT MsgP_Vcl_ID, Convert(FLOAT,MsgPC_PGNValue) AS MsgP_tMeterDis FROM  CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" INNER JOIN CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" ON MsgP_ID = MsgPC_MsgP_ID "+
							" and MsgPC_ID in ( SELECT Min(MsgPC_ID) MsgPC_ID  From CTY_Egn_B.dbo.Msg_PGN_"+tableDate+" inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgPC_MsgP_ID = MsgP_ID WHERE MsgPC_SysPIP_ID = 405 AND MsgPC_SysPI_ID = 65 AND MsgPC_PGNValue IS NOT NULL  GROUP BY MsgP_Vcl_ID))temp_meter on temp_meter.MsgP_Vcl_ID = VehicleID ";
				}
				paramKmSql += " where VehicleID = ? )tmp1 on 1=1 ";
						*//*"and (MsgT_tRunKmExact is not null or MsgT_tRunKm is not null or MsgT_tRunKmECU is not null) " +
						"and (MsgT_tRunKmExact>0 or MsgT_tRunKm>0 or MsgT_tRunKmECU>0) " +
						"and MsgT_tOilCons is not null and MsgT_tOilCons>0 " +
						"and MsgT_tWorkTime_UDS is not null and MsgT_tWorkTime_UDS>0 order by MsgT_ID asc)tmp1 " +
						"on 1=1";*//*
				*//**********仪表里程 ****LXF***20130722****BEGIN****
				String paramMeterSQL = "select CONVERT(float,tmpE.MsgPC_PGNValue)-CONVERT(float,tmpB.MsgPC_PGNValue) iMeterDistance from( "
					+"select top 1 MsgP_Vcl_ID,MsgPC_PGNValue,MsgP_MsgTime from V_VehicleInfo   "
					+"left join CTY_Egn_B.dbo.Msg_PGN_"+tableDate+"  on MsgP_Vcl_ID=VehicleID "
					+"inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+" on MsgP_ID=MsgPC_MsgP_ID "
					+"where MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID=? "
					+"order by MsgP_ID asc,MsgPC_ID asc)tmpB "
					+"left join ( "
					+"select top 1 MsgP_Vcl_ID,MsgPC_PGNValue,MsgP_MsgTime from V_VehicleInfo "
					+"left join CTY_Egn_B.dbo.Msg_PGN_"+tableDate+"  on MsgP_Vcl_ID=VehicleID "
					+"inner join CTY_Egn_B.dbo.Msg_PGN_Content_"+tableDate+"  on MsgP_ID=MsgPC_MsgP_ID "
					+"where MsgPC_SysPIP_ID=405 and MsgPC_SysPI_ID=65 and MsgPC_PGNValue is not null and MsgP_Vcl_ID=? "
					+"order by MsgP_ID desc,MsgPC_ID desc)tmpE on 1=1";
				/**********仪表里程 ****LXF***20130722****BEGIN*****//*
				for(Map<String,Object> firstDataHandlerMap:firstDataHandlerList){
					uFirstDataHandlerSqlList.add(uFirstDataHandlerSql);
					String vclID = MapGetter.getString(firstDataHandlerMap, "MsgSTP_VclID");
					Map<String,Object> paramMap = baseDAO.execQueryOne(paramKmSql, new Object[]{vclID,vclID});
//					Map<String,Object> paramMapMeter = baseDAO.execQueryOne(paramMeterSQL, new Object[]{vclID,vclID});
//					float iMeterDistance = 0 ;
//					if(StringUtil.isValid(MapGetter.getString(paramMap, "iRunKmExact_PGN"))){
//						iMeterDistance = this.getFloat(paramMap, "iRunKmExact_PGN");
//					}else{
//						iMeterDistance = this.getFloat(paramMapMeter, "iMeterDistance");
//					}
					uFirstDataHandlerParamList.add(new Object[]{this.getFloat(paramMap, "iOil"),
							this.getFloat(paramMap, "iKm"),this.getFloat(paramMap, "iTime"),
//							MapGetter.getString(paramMapMeter, "iMeterDistance"),
//							iMeterDistance,
							this.getFloat(paramMap, "MsgT_tRunKmExact_PGN"),
							this.getFloat(paramMap, "iRunKmExact"),this.getFloat(paramMap, "iRunKm"),this.getFloat(paramMap, "iRunKmECU"),
							MapGetter.getString(firstDataHandlerMap, "MsgSTP_ID")});
				}
				if(uFirstDataHandlerSqlList.size()>0)
					tranDAO.batch(uFirstDataHandlerSqlList, uFirstDataHandlerParamList);
			}else{
				String yesdayDataIstSQL414 = yesdayDataIstSQL.toString()+"and Tmnl_SoftEdition in ("+termSoftVer414.toString()+");";
				baseDAO.execInsert(yesdayDataIstSQL414, new Object[]{DateUtil.addDay(-1)});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		//当天值负数统一处理
		List<String> sqlList = new ArrayList<String>();
		String iETDistance = "update Message_Stat_TimingParam set MsgSTP_iETDistance=0 where MsgSTP_iETDistance<0;";
		String iOilCons = "update Message_Stat_TimingParam set MsgSTP_iOilCons=0 where MsgSTP_iOilCons<0;";
		String iEWorkHours = "update Message_Stat_TimingParam set MsgSTP_iEWorkHours=0 where MsgSTP_iEWorkHours<0;";
		//增加仪表里程当天值负数处理
		String iMeterDistance = "update Message_Stat_TimingParam set MsgSTP_iMeterDistance=0 where MsgSTP_iMeterDistance<0;";
		String iRunKmExact = "update Message_Stat_TimingParam set MsgSTP_iRunKmExact=0 where MsgSTP_iRunKmExact<0;";
		String iRunKm = "update Message_Stat_TimingParam set MsgSTP_iRunKm=0 where MsgSTP_iRunKm<0;";
		String iRunKmECU = "update Message_Stat_TimingParam set MsgSTP_iRunKmECU=0 where MsgSTP_iRunKmECU<0;";
		sqlList.add(iETDistance);
		sqlList.add(iOilCons);
		sqlList.add(iEWorkHours);
		sqlList.add(iMeterDistance);
		sqlList.add(iRunKmExact);
		sqlList.add(iRunKm);
		sqlList.add(iRunKmECU);
		tranDAO.batch(sqlList);
		//GPS里程更新
		this.updateGPSDistance(tableDate);
		System.out.println(DateUtil.toString(DateUtil.now(), "yyyy-MM-dd HH:mm:ss")+"]，统计的数据日期："+DateUtil.addDay(-1));
		*/		
	}
	/*
	 * 更新GPS里程
	 * 当天GPS里程值采用 两天的累计值做差的逻辑
	 * 20141016 jiyongtian 
	 **/
	private void updateGPSDistancenew() {
		StringBuffer gps = new StringBuffer();
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		gps.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance=temp.iGPSDistance,MsgSTP_tGPSDistance=temp.tGPSDistance ");
		gps.append("from(select tmp.VehicleID,CAST(round(convert(float,ISNULL(VclP_TMileage-VclP_TMileage_min,0))*1.0,2) as decimal(18,2)) as iGPSDistance, ");
		gps.append("tGPSDistance = case when VclP_TMileage is not null and VclP_TMileage>0 then VclP_TMileage else ISNULL(tmp.MsgSTP_tGPSDistance,0) end  ");
		gps.append("from ( select vv.VehicleID, ");
		gps.append("VclP_TMileage = (select top 1 VclP_TMileage from CTY_Vcl.dbo.Vcl_Pstn_"+tableDate+" where VclP_Vcl_ID = VehicleID and VclP_TMileage is not null and VclP_TMileage > 0 order by VclP_PstnTime desc), ");
		gps.append("VclP_TMileage_min = case when (0=isnull(mst.MsgSTP_tGPSDistance,0)) then (select top 1 VclP_TMileage from CTY_Vcl.dbo.Vcl_Pstn_"+tableDate+" where VclP_Vcl_ID = VehicleID and VclP_TMileage is not null and VclP_TMileage > 0 order by VclP_PstnTime) else mst.MsgSTP_tGPSDistance end,  ");
		gps.append("mst.MsgSTP_tGPSDistance from V_VehicleInfo vv  ");
		gps.append("left join (select * from Message_Stat_TimingParam where MsgSTP_StatTime = ? ) mst on mst.MsgSTP_VclID = VehicleID   ");
		gps.append("where UsefulLife>=GETDATE() and Tmnl_SoftEdition is not null and Tmnl_SoftEdition <> '' )tmp  ");
		gps.append(")temp where MsgSTP_StatTime = ? and temp.VehicleID = MsgSTP_VclID ");
		this.baseDAO.execUpdate(gps.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});
	}

	/*更新GPS里程*/
	private void updateGPSDistance(String yesterday) {
	    if(!StringUtil.isValid(yesterday)){
	    	yesterday = DateUtil.addDay(-1).replace("-", "");
	    }
	    List<String> sqlGPS = new ArrayList<String>();
		String strSQL_GPS = "select count(1) as counts  from CTY_Vcl.dbo.SysObjects where XType = 'U' and Name =?";
		Map<String,Object> msgGPS = baseDAO.execQueryOne(strSQL_GPS, new Object[]{"Vcl_Pstn_"+yesterday});
		//不存在位置表，则把GPS信息更新为0
		if(!(msgGPS.get("counts").toString().equals("1"))){
			StringBuffer inullGPS  = new StringBuffer();
			//StringBuffer tnullGPS  = new StringBuffer();当日gps里程可以直接设置为0；start
			inullGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = 0 where MsgSTP_StatTime = '"+DateUtil.addDay(-1)+"';");
			//tnullGPS.append("update Message_Stat_TimingParam set MsgSTP_tGPSDistance = 0 where MsgSTP_StatTime = '"+yesterday+"';");
			sqlGPS.add(inullGPS.toString());
            //sqlGPS.add(tnullGPS.toString());
			//当日gps里程可以直接设置为0；end
			//累计GPS里程使用前一天的有效值start
			String strStaSQL="select MsgSTP_ID as msgstpid ,MsgSTP_tGPSDistance as msgstp_tgpsdistance, MsgSTP_StatTime from Message_Stat_TimingParam where MsgSTP_StatTime=?";
			List<Map<String,Object>> staList = baseDAO.execQuery(strStaSQL, new Object[]{DateUtil.addDay(-2)});
			for(Map<String,Object> oneSta:staList){
				String tgps = "update Message_Stat_TimingParam set MsgSTP_tGPSDistance = "+oneSta.get("msgstp_tgpsdistance")+" where MsgSTP_ID = "+oneSta.get("msgstpid").toString()+" and MsgSTP_StatTime = '"+DateUtil.addDay(-1)+"';";
				sqlGPS.add(tgps);
			}
			//累计GPS里程使用前一天的有效值end
		}
		else{
			String strSQL="select MsgSTP_ID as msgstpid ,MsgSTP_tGPSDistance as msgstp_tgpsdistance,MsgSTP_VclID as vclid,MsgSTP_StatTime from Message_Stat_TimingParam where MsgSTP_StatTime=?";
			List<Map<String,Object>> list = baseDAO.execQuery(strSQL, new Object[]{DateUtil.addDay(-1)});
			for(Map<String,Object> map:list){
				StringBuffer iupdateGPS = new StringBuffer();
				//StringBuffer tupdateGPS = new StringBuffer();
				String vclid= MapGetter.getString(map,"vclid");
//				System.out.println("设备ID："+vclid);
				if(StringUtil.isValid(vclid)){
					StringBuffer strGPSquery = new StringBuffer();
					strGPSquery.append(" select vp2.VclP_Vcl_ID as vclid,MAX(CAST(round(convert(float,ISNULL(vp2.VclP_IMileage,0))*1.0,2) as decimal(18,2))) as igpsdistance,");
					strGPSquery.append(" MAX(CAST(round(convert(float,ISNULL(vp2.VclP_TMileage,0))*1.0,2) as decimal(18,2))) as tgpsdistance ");
					strGPSquery.append(" from ((select VclP_Vcl_ID,max(vclp_id) as vclp_id  from CTY_Vcl.dbo.Vcl_Pstn_"+yesterday);
					strGPSquery.append(" where VclP_MsgTp_ID=2 and vclp_imileage >0 and VclP_Vcl_ID='"+vclid+"' group by VclP_Vcl_ID " +
							" union all  SELECT  vclp_vcl_id,Max(vclp_id) AS vclp_id FROM  cty_vcl.dbo.vcl_pstn_"+yesterday+
							" WHERE vclp_msgtp_id = 2 AND vclp_tmileage > 0 AND vclp_vcl_id = '"+vclid+"' GROUP BY vclp_vcl_id ) as vp1 left join ");	
					strGPSquery.append(" (select vclP_ID,VclP_Vcl_ID,VclP_IMileage = case when VclP_IMileage is NULL then 0 else VclP_IMileage end ,");
					strGPSquery.append(" VclP_TMileage  = case when VclP_TMileage is NULL then 0 else VclP_TMileage end ,VclP_MsgTp_ID ");
					strGPSquery.append(" from CTY_Vcl.dbo.Vcl_Pstn_"+yesterday+" ) vp2 on vp1.VclP_Vcl_ID = vp2.VclP_Vcl_ID and vp1.vclp_id = vp2.vclP_ID");
					strGPSquery.append(" left join V_VehicleInfo on vp1.VclP_Vcl_ID = VehicleID ) GROUP BY vp2.VclP_Vcl_ID ");
					Map<String,Object> gpsmap = baseDAO.execQueryOne(strGPSquery.toString(), new Object[]{});
					String igpsdistance; //= MapGetter.getString(gpsmap,"igpsdistance");//  gpsmap.get("igpsdistance").toString();
					if(null != gpsmap.get("igpsdistance")){
						igpsdistance = gpsmap.get("igpsdistance").toString();
					}
					else{
						igpsdistance="";
					}
					String tgpsdistance ;//= MapGetter.getString(gpsmap,"tgpsdistance");//gpsmap.get("tgpsdistance").toString();
					if(null != gpsmap.get("tgpsdistance") ){
						tgpsdistance = gpsmap.get("tgpsdistance").toString();
					}
					else{
						tgpsdistance="";
					}
					if(StringUtil.isValid(igpsdistance)&&StringUtil.isValid(tgpsdistance)){
						if(Float.parseFloat(tgpsdistance)!= 0){
							iupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = "+igpsdistance+", MsgSTP_tGPSDistance = "+tgpsdistance+"  where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
						}else{
							String preSQL="select MsgSTP_tGPSDistance as msgstp_tgpsdistance,MsgSTP_VclID as vclid  from Message_Stat_TimingParam where MsgSTP_StatTime='"+DateUtil.addDay(-2)+"' and MsgSTP_VclID ='"+vclid+"'";
							Map<String,Object> pretemp = this.baseDAO.execQueryOne(preSQL, new Object[]{});
							if(null!=pretemp.get("msgstp_tgpsdistance")){
								iupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = "+igpsdistance+", MsgSTP_tGPSDistance = "+pretemp.get("msgstp_tgpsdistance").toString()+"  where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
							}else{
								iupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = "+igpsdistance+", MsgSTP_tGPSDistance = "+tgpsdistance+"  where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
							}
						}
						//tupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_tGPSDistance = "+tgpsdistance+" where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
					}
					else{
						String preSQL="select MsgSTP_tGPSDistance as msgstp_tgpsdistance,MsgSTP_VclID as vclid  from Message_Stat_TimingParam where MsgSTP_StatTime='"+DateUtil.addDay(-2)+"' and MsgSTP_VclID ='"+vclid+"'";
						Map<String,Object> pre = this.baseDAO.execQueryOne(preSQL, new Object[]{});
						if(null!=pre.get("msgstp_tgpsdistance")){
							iupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = 0,MsgSTP_tGPSDistance = "+pre.get("msgstp_tgpsdistance").toString()+" where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
						}else{
							iupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = 0,MsgSTP_tGPSDistance = 0 where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
						}
						//tupdateGPS.append("update Message_Stat_TimingParam set MsgSTP_tGPSDistance = 0 where MsgSTP_ID = '"+map.get("msgstpid").toString()+"';");
					}
					sqlGPS.add(iupdateGPS.toString());
					//sqlGPS.add(tupdateGPS.toString());
				}
				else{
					System.out.println("设备ID为空");
				}				
			}
/*		
			StringBuffer strGPSquery = new StringBuffer();
			strGPSquery.append(" select vp2.VclP_Vcl_ID as vclid,CAST(round(convert(float,ISNULL(vp2.VclP_IMileage,0))*1.0,2) as decimal(18,2)) as igpsdistance,");
			strGPSquery.append(" CAST(round(convert(float,ISNULL(vp2.VclP_TMileage,0))*1.0,2) as decimal(18,2)) as tgpstistance ");
			strGPSquery.append(" from ((select VclP_Vcl_ID,max(vclp_id) as vclp_id  from CTY_Vcl.dbo.Vcl_Pstn_"+yesterday);
			strGPSquery.append(" where VclP_MsgTp_ID=2 group by VclP_Vcl_ID ) as vp1 left join ");	
			strGPSquery.append(" (select vclP_ID,VclP_Vcl_ID,VclP_IMileage = case when VclP_IMileage is NULL then 0 else VclP_IMileage end ,");
			strGPSquery.append(" VclP_TMileage  = case when VclP_TMileage is NULL then 0 else VclP_TMileage end ,VclP_MsgTp_ID ");
			strGPSquery.append(" from CTY_Vcl.dbo.Vcl_Pstn_"+yesterday+" ) vp2 on vp1.VclP_Vcl_ID = vp2.VclP_Vcl_ID and vp1.vclp_id = vp2.vclP_ID");
			strGPSquery.append(" left join V_VehicleInfo on vp1.VclP_Vcl_ID = VehicleID )");
			List<Map<String,Object>> listgps = baseDAO.execQuery(strGPSquery.toString(), new Object[]{});
			if(list != null && listgps != null){
				list = this.mergeListSomeKind(list,listgps,"vclid");
				for(Map<String,Object> conMap:list){
					StringBuffer conBuf = new StringBuffer();
					conBuf.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = "+conMap.get("igpsdistance").toString()+" where MsgSTP_ID = '"+conMap.get("msgstpid").toString()+"';");
					conBuf.append("update Message_Stat_TimingParam set MsgSTP_tGPSDistance = "+conMap.get("tgpsdistance").toString()+" where MsgSTP_ID = '"+conMap.get("msgstpid").toString()+"';");
					sqlGPS.add(conBuf.toString());
				}
			}
			*/
		}
		if(sqlGPS.size()!= 0){
			tranDAO.batch(sqlGPS);
		}
		List<String> check = new ArrayList<String>();
		StringBuffer strcheck = new StringBuffer();
		strcheck.append("update Message_Stat_TimingParam set MsgSTP_iGPSDistance = 0 where MsgSTP_StatTime = '"+DateUtil.addDay(-1)+"' and MsgSTP_iGPSDistance < 0;");
		strcheck.append("update Message_Stat_TimingParam set MsgSTP_tGPSDistance = 0 where MsgSTP_StatTime = '"+DateUtil.addDay(-1)+"' and MsgSTP_tGPSDistance < 0;");
		check.add(strcheck.toString());
		tranDAO.batch(check);
		
	}
	
    /*两个list里的map对象有一个相同的key并且同一个list的不同map对应此key的value不同，将两个list按照第一个list的size()合并
	private List<Map<String, Object>> mergeListSomeKind(
			List<Map<String, Object>> list, List<Map<String, Object>> listgps,String sameKey) {
		for(int i=0;i<list.size();i++){
			Map<String,Object> map = list.get(i);
			String field = map.get(sameKey).toString();
			if(StringUtil.isValid(field)){
				int count=0;
				for(Map<String,Object> gpsmap:listgps){
					if(gpsmap.get(sameKey).toString().equals(field)){
						map.put("igpsdistance", gpsmap.get("igpsdistance"));
						map.put("tgpsdistance", gpsmap.get("tgpsdistance"));
					}
					else{
						count++;
					}
				}
				if(count==(listgps.size()-1)){
					map.put("igpsdistance", "0");
					map.put("tgpsdistance", "0");
				}
			}
		}
		return list;
	}
	*/	
	/**
	 * 获取上一次统计日期
	 * @return
	 */
	public String getLastDateTime(){
		String strSQL = "select top 1 convert(varchar(10),MsgSTP_StatTime,120) as dt from Message_Stat_TimingParam order by MsgSTP_StatTime desc";
		Map<String,Object> map = baseDAO.execQueryOne(strSQL, new Object[]{});
		String retValue = "";
		if(map.get("dt")!=null)retValue = map.get("dt").toString();
		return retValue;
	}
	
	public float getFloat(Map<String,Object> map,String key){
		try{
			if(StringUtil.isNullOrEmpty(MapGetter.getString(map, key))){
				return Float.parseFloat(MapGetter.getString(map, key));
			}else{
				return 0;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return 0;
	}
	
	/***
	 * 更新设备怠速时长
	 */
	private void updateVclIdleSpeedTime(){
		StringBuffer idBoStr = new StringBuffer();
		StringBuffer idJStr = new StringBuffer();
		StringBuffer idPpStr = new StringBuffer();
		StringBuffer idJppStr = new StringBuffer();
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		String termSoftVerBo = EquipVersionCommon.getSoftVerByAgrType("Vcl_D");
		String termSoftVerJ = EquipVersionCommon.getSoftVerByAgrType("Vcl_J");
		String termSoftVerPp = EquipVersionCommon.getSoftVerByAgrType("Vcl_PP");
		String termSoftVerJpp = EquipVersionCommon.getSoftVerByAgrType("Vcl_JPP");
		//更新大一设备怠速时长，直接赋值为0
		idBoStr.append("update Message_Stat_TimingParam set MsgSTP_iIdleTime = 0 ,MsgSTP_tIdleTime = 0 where MsgSTP_StatTime = ? and MsgSTP_VclID in (select vehicleid from v_vehicleinfo where Tmnl_SoftEdition in("+termSoftVerBo+"))");
		this.baseDAO.execUpdate(idBoStr.toString(), new Object[]{this.thisWorkDay});
		//更新小一J设备怠速时长，取CAN参数
		idJStr.append("update message_stat_timingparam set MsgSTP_iIdleTime = tmpt.iidletime,MsgSTP_tIdleTime = tmpt.tidletime ");
		idJStr.append("FROM (select vehicleid,");
		idJStr.append("Cast(Round(Convert(FLOAT,Isnull(tmp.tidletime - (SELECT CASE WHEN 0 = Isnull(MsgSTP_tIdleTime,0) THEN (SELECT top 1 msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
		idJStr.append("WHERE msgcco_syscp_id = 25 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid ORDER BY msgc_msgtime)ELSE MsgSTP_tIdleTime END FROM message_stat_timingparam WHERE msgstp_vclid = vehicleid AND msgstp_stattime = ?),0)) * 1.0,2) AS DECIMAL(18,2)) AS iidletime,");
		idJStr.append("tidletime = CASE WHEN tmp.tidletime IS NOT NULL AND tmp.tidletime > 0 THEN tmp.tidletime ELSE Isnull((SELECT MsgSTP_tIdleTime FROM message_stat_timingparam WHERE msgstp_stattime =? AND msgstp_vclid = vehicleid),0) END ");
		idJStr.append("from(SELECT vehicleid,tidletime = (SELECT   top 1  msgcco_parmvalue FROM cty_egn_b.dbo.msg_can_"+tableDate+" mc INNER JOIN cty_egn_b.dbo.msg_can_content_"+tableDate+" ON msgc_id = msgcco_msgc_id ");
		idJStr.append("WHERE msgcco_syscp_id = 25 AND msgcco_parmvalue IS NOT NULL AND msgcco_parmvalue > 0 AND msgc_vcl_id = vehicleid  ORDER BY msgc_msgtime DESC)FROM v_vehicleinfo AS vehicleinfo ");
		idJStr.append("WHERE UsefulLife>=GETDATE() and Tmnl_SoftEdition in("+termSoftVerJ+"))tmp");
		idJStr.append(") tmpt where MsgSTP_VclID = tmpt.VehicleID and MsgSTP_StatTime = ?");
		baseDAO.execUpdate(idJStr.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay,this.thisWorkDay});
		/**  目前系统内无PP设备，可以暂时先去掉
		//更新PP设备怠速时长
		idPpStr.append("UPDATE message_stat_timingparam SET MsgSTP_iIdleTime = TEMP.iIdleWorkTime, MsgSTP_tIdleTime = TEMP.tIdleWorkTime FROM (SELECT tmp.vehicleid,");
		idPpStr.append("Cast(Round(Convert(FLOAT,Isnull(msgt_tIdleWorkTime - msgt_tIdleWorkTime_min,0)) * 1.0,2) AS DECIMAL(18,2)) AS iIdleWorkTime,");
		idPpStr.append("tIdleWorkTime = CASE WHEN msgt_tIdleWorkTime IS NOT NULL AND msgt_tIdleWorkTime > 0 THEN msgt_tIdleWorkTime ELSE Isnull(tmp.MsgSTP_tIdleTime,0) END ");
		idPpStr.append("FROM (SELECT vv.vehicleid,msgt_tIdleWorkTime = Isnull((SELECT   top 1  MsgT_tIdleWorkTime_UDS FROM cty_egn_b.dbo.msg_timing_"+tableDate+" WHERE msgt_vcl_id = vehicleid AND MsgT_tIdleWorkTime_UDS IS NOT NULL  AND MsgT_tIdleWorkTime_UDS > 0  ORDER BY msgt_msgtime DESC),");
		idPpStr.append("Isnull((SELECT   top 1  msgu_vcl_id, Convert(FLOAT,msguc_udsvalue) AS msgu_tIdleWorkTime FROM cty_egn_b.dbo.msg_uds_"+tableDate+" INNER JOIN cty_egn_b.dbo.msg_uds_content_"+tableDate+" ON msguc_msgu_id = msgu_id  WHEREmsgu_vcl_id = VehicleID AND msguc_udsid = '2FF2' ");
		idPpStr.append("AND msguc_udsvalue IS NOT NULL  AND Convert(FLOAT,msguc_udsvalue) > 0 ORDER BY msgu_msgtime DESC),0)), msgt_tIdleWorkTime_min= CASE  WHEN (0 = Isnull(mst.MsgSTP_tIdleTime,0)) THEN Isnull((SELECT   top 1  MsgT_tIdleWorkTime_UDS FROM cty_egn_b.dbo.msg_timing_"+tableDate+" ");
		idPpStr.append("WHERE msgt_vcl_id = vehicleid AND MsgT_tIdleWorkTime_UDS IS NOT NULL AND MsgT_tIdleWorkTime_UDS > 0  ORDER BY msgt_msgtime),Isnull((SELECT   top 1  msgu_vcl_id, Convert(FLOAT,msguc_udsvalue) AS msgu_tIdleWorkTime FROM  cty_egn_b.dbo.msg_uds_"+tableDate+" INNER JOIN cty_egn_b.dbo.msg_uds_content_"+tableDate+" ");
		idPpStr.append("ON msguc_msgu_id = msgu_id WHERE msgu_vcl_id = VehicleID AND msguc_udsid = '2FF2' AND msguc_udsvalue IS NOT NULL AND Convert(FLOAT,msguc_udsvalue) > 0 ORDER BY msgu_msgtime),0))  ELSE mst.MsgSTP_tIdleTime  END,mst.MsgSTP_tIdleTime FROM   v_vehicleinfo vv ");
		idPpStr.append("LEFT JOIN (SELECT * FROM message_stat_timingparam WHERE  msgstp_stattime = ?) mst ON mst.msgstp_vclid = vehicleid WHERE usefullife >= Getdate() AND tmnl_softedition IN ("+termSoftVerPp+")) tmp) TEMP WHERE  msgstp_stattime = ? AND TEMP.vehicleid = msgstp_vclid");
		baseDAO.execUpdate(idPpStr.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});
		**/
		//更新JPP设备怠速时长
		idJppStr.append("UPDATE message_stat_timingparam SET MsgSTP_iIdleTime = TEMP.iIdleWorkTime, MsgSTP_tIdleTime = TEMP.tIdleWorkTime FROM (SELECT tmp.vehicleid,");
		idJppStr.append("Cast(Round(Convert(FLOAT,Isnull(msgt_tIdleWorkTime - msgt_tIdleWorkTime_min,0)) * 1.0,2) AS DECIMAL(18,2)) AS iIdleWorkTime,");
		idJppStr.append("tIdleWorkTime = CASE WHEN msgt_tIdleWorkTime IS NOT NULL AND msgt_tIdleWorkTime > 0 THEN msgt_tIdleWorkTime ELSE Isnull(tmp.MsgSTP_tIdleTime,0) END ");
		idJppStr.append("FROM (SELECT vv.vehicleid,msgt_tIdleWorkTime = Isnull((SELECT   top 1  MsgT_tIdleWorkTime_UDS FROM cty_egn_b.dbo.msg_timing_"+tableDate+" WHERE msgt_vcl_id = vehicleid AND MsgT_tIdleWorkTime_UDS IS NOT NULL  AND MsgT_tIdleWorkTime_UDS > 0  ORDER BY msgt_msgtime DESC),");
		idJppStr.append("Isnull((SELECT   top 1  Convert(FLOAT,msgpc_pgnvalue) AS msgp_tIdleWorkTime FROM cty_egn_b.dbo.msg_pgn_"+tableDate+" INNER JOIN cty_egn_b.dbo.msg_pgn_content_"+tableDate+" ON msgp_id = msgpc_msgp_id  WHERE msgp_vcl_id = vehicleid AND msgpc_syspip_id = 12 AND msgpc_syspi_id = 8 ");
		idJppStr.append("AND msgpc_pgnvalue IS NOT NULL AND Convert(FLOAT,msgpc_pgnvalue) > 0 ORDER BY msgp_msgtime DESC),0)), msgt_tIdleWorkTime_min= CASE  WHEN (0 = Isnull(mst.MsgSTP_tIdleTime,0)) THEN Isnull((SELECT   top 1  MsgT_tIdleWorkTime_UDS FROM cty_egn_b.dbo.msg_timing_"+tableDate+" ");
		idJppStr.append("WHERE msgt_vcl_id = vehicleid AND MsgT_tIdleWorkTime_UDS IS NOT NULL AND MsgT_tIdleWorkTime_UDS > 0  ORDER BY msgt_msgtime),Isnull((SELECT top 1  Convert(FLOAT,msgpc_pgnvalue) AS msgp_tIdleWorkTime FROM cty_egn_b.dbo.msg_pgn_"+tableDate+" INNER JOIN cty_egn_b.dbo.msg_pgn_content_"+tableDate+" ");
		idJppStr.append("ON msgp_id = msgpc_msgp_id WHERE msgp_vcl_id = vehicleid  AND msgpc_syspip_id = 12 AND msgpc_syspi_id = 8 AND msgpc_pgnvalue IS NOT NULL AND Convert(FLOAT,msgpc_pgnvalue) > 0 ORDER BY msgp_msgtime),0))  ELSE mst.MsgSTP_tIdleTime  END,mst.MsgSTP_tIdleTime FROM   v_vehicleinfo vv ");
		idJppStr.append("LEFT JOIN (SELECT * FROM message_stat_timingparam WHERE  msgstp_stattime = ?) mst ON mst.msgstp_vclid = vehicleid WHERE usefullife >= Getdate() AND tmnl_softedition IN ("+termSoftVerJpp+")) tmp) TEMP WHERE  msgstp_stattime = ? AND TEMP.vehicleid = msgstp_vclid");
		baseDAO.execUpdate(idJppStr.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});
	}
	
	/**
	 * 更新设备平均载重
	 */
	private void updateVclAvgLoad(){
		
		StringBuffer vclLoadStr = new StringBuffer();
		/**-载重统计时间较长，故今天更新前天的 载重数据-**/
		vclLoadStr.append("update Message_Stat_TimingParam set MsgSTP_avgLoad = tmp.avgLoad from (");
		/*vclLoadStr.append("select MsgLS_Vcl_ID,round(sum(MsgLS_AvgLoad*MsgLS_SecKms)/(sum(MsgLS_SecKms)*1000),1) as avgLoad from  (");*/
		vclLoadStr.append("select MsgLS_Vcl_ID,avgload = Case when Sum(msgls_seckms)=0 then 0 else Round(Sum(msgls_avgload * msgls_seckms) / (Sum(msgls_seckms) * 1000), 1) end from  (");
		vclLoadStr.append("select MsgLS_Vcl_ID,MsgLS_AvgLoad,MsgLS_StatTime,MsgLS_SecKms =case VehicleRumKmID when 1 then MsgLS_SecMeterDistance ");
		vclLoadStr.append("when 2 then MsgLS_SecRunKmExact when 3 then MsgLS_SecRunKm when 4 then MsgLS_SecRunKmECU when 5 then MsgLS_SecGPSDistance ");
		vclLoadStr.append("else MsgLS_SecMeterDistance end from Msg_LoadStat inner join V_VehicleInfo on MsgLS_Vcl_ID = vehicleid) tt where MsgLS_StatTime = ? ");
		vclLoadStr.append("group by MsgLS_Vcl_ID ) tmp where MsgSTP_VclID = MsgLS_Vcl_ID and MsgSTP_StatTime =?");
	    baseDAO.execUpdate(vclLoadStr.toString(), new Object[]{this.lastWorkDay,this.lastWorkDay});
	}
	
	/**
	 * 更新设备尿素消耗量
	 */
	private void updateVclUreo(){
		String tableDate = this.thisWorkDay.replaceAll("-", "");
		String termSoftVerJpp = EquipVersionCommon.getSoftVerByAgrType("Vcl_JPP");
		StringBuffer vclUreaStr = new StringBuffer();
		vclUreaStr.append("UPDATE message_stat_timingparam SET MsgSTP_iUraeValue = TEMP.iUraeValue,MsgSTP_tUraeValue = TEMP.tiUraeValue FROM (");
		vclUreaStr.append("SELECT tmp.vehicleid,Cast(Round(Convert(FLOAT,Isnull(msgt_tiUraeValue - msgt_tiUraeValue_min,0)) * 1.0,2) AS DECIMAL(18,2)) AS iUraeValue,");
		vclUreaStr.append("tiUraeValue = CASE WHEN msgt_tiUraeValue IS NOT NULL AND msgt_tiUraeValue > 0 THEN msgt_tiUraeValue ELSE Isnull(tmp.msgt_tiUraeValue,0)  END  FROM   (");
		vclUreaStr.append("SELECT vv.vehicleid,msgt_tiUraeValue= Isnull((SELECT top 1  Convert(FLOAT,msguc_udsvalue) AS msgu_tiUraeValue FROM  cty_egn_b.dbo.msg_uds_"+tableDate+" ");
		vclUreaStr.append(" INNER JOIN cty_egn_b.dbo.msg_uds_content_"+tableDate+" ON msguc_msgu_id = msgu_id WHERE msgu_vcl_id = VehicleID AND msguc_udsid = 'B7E2' AND msguc_udsvalue IS NOT NULL ");
		vclUreaStr.append(" AND Convert(FLOAT,msguc_udsvalue) > 0 ORDER BY msgu_msgtime DESC),0),msgt_tiUraeValue_min = CASE WHEN (0 = Isnull(mst.MsgSTP_tUraeValue,0)) THEN Isnull((SELECT   top 1 ");
		vclUreaStr.append("Convert(FLOAT,msguc_udsvalue) AS msgu_tiUraeValue FROM  cty_egn_b.dbo.msg_uds_"+tableDate+" INNER JOIN cty_egn_b.dbo.msg_uds_content_"+tableDate+" ON msguc_msgu_id = msgu_id ");
		vclUreaStr.append(" WHERE msgu_vcl_id = VV.VehicleID AND msguc_udsid = 'B7E2' AND msguc_udsvalue IS NOT NULL AND Convert(FLOAT,msguc_udsvalue) > 0 ORDER BY msgu_msgtime),0) ELSE mst.MsgSTP_tUraeValue END ");
		vclUreaStr.append(" FROM  v_vehicleinfo VV LEFT JOIN (SELECT * FROM message_stat_timingparam WHERE  msgstp_stattime = ?)mst ON mst.msgstp_vclid = vehicleid WHERE usefullife >= Getdate() ");
		vclUreaStr.append(" AND tmnl_softedition IN ("+termSoftVerJpp+")) tmp) TEMP WHERE msgstp_stattime = ? AND TEMP.vehicleid = msgstp_vclid ");
		baseDAO.execUpdate(vclUreaStr.toString(), new Object[]{this.lastWorkDay,this.thisWorkDay});
	}
}